Sync all scripts from website downloads — 352 scripts total
Includes updated JS challenge scripts with Claude-User whitelist, same-site referer bypass, Blackbox-Exporter allowed bot, and all new exporters, cheat sheets, and automation scripts.
This commit is contained in:
+24
-15
@@ -9,7 +9,7 @@
|
||||
# Author: Phil Connor
|
||||
# Contact: contact@mylinux.work
|
||||
# License: MIT
|
||||
# Version: 1.0.0
|
||||
# Version: 1.0.1
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
@@ -27,28 +27,23 @@ TARGET_DIRECTORIES=()
|
||||
# ── Metrics Collection ──────────────────────────────────────────────
|
||||
|
||||
log_verbose() {
|
||||
[[ "$VERBOSE" == true ]] && echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >&2
|
||||
[[ "$VERBOSE" == true ]] && echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >&2 || true
|
||||
}
|
||||
|
||||
log_info() {
|
||||
[[ "$QUIET" == false ]] && echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >&2
|
||||
[[ "$QUIET" == false ]] && echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >&2 || true
|
||||
}
|
||||
|
||||
collect_metrics() {
|
||||
local start_time
|
||||
start_time=$(date +%s%N)
|
||||
|
||||
echo "# HELP node_directory_size_bytes Disk space used by directory"
|
||||
echo "# TYPE node_directory_size_bytes gauge"
|
||||
echo "# HELP node_directory_filesystem_usage_percent Filesystem usage percentage for the directory mount point"
|
||||
echo "# TYPE node_directory_filesystem_usage_percent gauge"
|
||||
|
||||
local success=1
|
||||
local size_lines="" pct_lines=""
|
||||
|
||||
for directory in "${TARGET_DIRECTORIES[@]}"; do
|
||||
log_verbose "Running du for: $directory"
|
||||
|
||||
# Get directory size in bytes
|
||||
local du_output
|
||||
du_output=$(timeout "$TIMEOUT" du --block-size=1 --summarize "$directory" 2>/dev/null) || {
|
||||
log_info "WARNING: du failed for $directory"
|
||||
@@ -58,16 +53,24 @@ collect_metrics() {
|
||||
|
||||
local size_bytes
|
||||
size_bytes=$(echo "$du_output" | awk '{print $1}')
|
||||
echo "node_directory_size_bytes{directory=\"${directory}\"} ${size_bytes}"
|
||||
size_lines+="node_directory_size_bytes{directory=\"${directory}\"} ${size_bytes}"$'\n'
|
||||
|
||||
# Get filesystem usage percentage for the mount point
|
||||
local pct
|
||||
pct=$(df --output=pcent "$directory" 2>/dev/null | tail -n 1 | tr -d ' %')
|
||||
if [[ "$pct" =~ ^[0-9]+$ ]]; then
|
||||
echo "node_directory_filesystem_usage_percent{directory=\"${directory}\"} ${pct}"
|
||||
pct_lines+="node_directory_filesystem_usage_percent{directory=\"${directory}\"} ${pct}"$'\n'
|
||||
fi
|
||||
done
|
||||
|
||||
echo "# HELP node_directory_size_bytes Disk space used by directory"
|
||||
echo "# TYPE node_directory_size_bytes gauge"
|
||||
printf "%s" "$size_lines"
|
||||
|
||||
echo ""
|
||||
echo "# HELP node_directory_filesystem_usage_percent Filesystem usage percentage for the directory mount point"
|
||||
echo "# TYPE node_directory_filesystem_usage_percent gauge"
|
||||
printf "%s" "$pct_lines"
|
||||
|
||||
# ── Script runtime ──
|
||||
local end_time runtime
|
||||
end_time=$(date +%s%N)
|
||||
@@ -78,10 +81,12 @@ collect_metrics() {
|
||||
echo "# TYPE ${EXPORTER_NAME}_duration_seconds gauge"
|
||||
echo "${EXPORTER_NAME}_duration_seconds ${runtime}"
|
||||
|
||||
echo ""
|
||||
echo "# HELP ${EXPORTER_NAME}_last_run_timestamp Last successful run"
|
||||
echo "# TYPE ${EXPORTER_NAME}_last_run_timestamp gauge"
|
||||
echo "${EXPORTER_NAME}_last_run_timestamp $(date +%s)"
|
||||
|
||||
echo ""
|
||||
echo "# HELP ${EXPORTER_NAME}_success Whether the exporter ran successfully"
|
||||
echo "# TYPE ${EXPORTER_NAME}_success gauge"
|
||||
echo "${EXPORTER_NAME}_success ${success}"
|
||||
@@ -191,8 +196,8 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
;;
|
||||
--handle-request)
|
||||
handle_request
|
||||
exit 0
|
||||
OUTPUT_MODE="handle-request"
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
show_help
|
||||
@@ -236,6 +241,10 @@ if [[ "$DRY_RUN" == true ]]; then
|
||||
fi
|
||||
|
||||
case "$OUTPUT_MODE" in
|
||||
handle-request)
|
||||
handle_request
|
||||
exit 0
|
||||
;;
|
||||
stdout)
|
||||
collect_metrics
|
||||
;;
|
||||
@@ -262,6 +271,6 @@ case "$OUTPUT_MODE" in
|
||||
fi
|
||||
echo "${EXPORTER_NAME} listening on port ${PORT}..."
|
||||
echo "Monitoring directories: ${TARGET_DIRECTORIES[*]}"
|
||||
socat TCP-LISTEN:"$PORT",reuseaddr,fork EXEC:"$0 --handle-request"
|
||||
socat TCP-LISTEN:"$PORT",reuseaddr,fork EXEC:"$0 --handle-request ${TARGET_DIRECTORIES[*]}"
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user