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:
2026-05-25 03:31:08 +02:00
parent dbd6bf0324
commit a1a17e81a1
332 changed files with 174509 additions and 1106 deletions
+112 -2
View File
@@ -1,7 +1,7 @@
#!/bin/bash
################################################################################
# Script Name: salt-master-metrics.sh
# Version: 3.1
# Version: 3.2
# Author: Phil Connor, contact@mylinux.work
# License: MIT
# Description: Production Prometheus exporter for Salt Master metrics
@@ -39,6 +39,8 @@
# stdout Default: print metrics to stdout
#
# Changelog:
# 3.2 - Added per-minion highstate detail metrics (succeeded/failed/changed
# state counts per minion from most recent highstate run)
# 3.1 - Added per-function expected/actual response metrics, per-function
# new job metrics with success/failure, scheduled job return
# metrics per minion/function/state. All from job cache parsing.
@@ -53,7 +55,7 @@
# 1.0 - Initial release
################################################################################
SCRIPT_VERSION="3.1"
SCRIPT_VERSION="3.2"
TEXTFILE_DIR="/var/lib/node_exporter"
OUTPUT_FILE=""
HTTP_MODE=false
@@ -232,6 +234,108 @@ cache_highstate_data() {
}
# ---------------------------------------------------------------------------
# Per-minion highstate detail metrics (succeeded/failed/changed per minion)
# Scans job cache for most recent highstate per minion, counts state results.
# ---------------------------------------------------------------------------
generate_highstate_detail_metrics() {
if [ ! -d "$SALT_CACHE_DIR/jobs" ]; then
return
fi
declare -A minion_succeeded
declare -A minion_failed
declare -A minion_changed
declare -A minion_jid
local jid_dirs
jid_dirs=$(find "$SALT_CACHE_DIR/jobs" -name ".load.p" -type f -mmin -1440 2>/dev/null | head -n "$JOB_CACHE_SCAN_MAX")
if [ -z "$jid_dirs" ]; then
return
fi
while IFS= read -r load_file; do
[ -z "$load_file" ] && continue
local job_dir func_name
job_dir=$(dirname "$load_file")
func_name=""
if [ -n "$JOB_LIST_CACHE" ]; then
local jid_tail jid_prefix full_jid
jid_tail=$(basename "$job_dir")
jid_prefix=$(basename "$(dirname "$job_dir")")
full_jid="${jid_prefix}${jid_tail}"
func_name=$(echo "$JOB_LIST_CACHE" | grep -A5 "$full_jid" 2>/dev/null \
| grep -i "Function:" | head -1 | sed 's/.*Function:[[:space:]]*//' | tr -d '[:space:]')
fi
if [ -z "$func_name" ]; then
local load_strings
load_strings=$(timeout 2 strings "$load_file" 2>/dev/null || true)
func_name=$(echo "$load_strings" | grep -oE '(state\.[a-z_]+)' | head -1)
fi
# Only process highstate jobs (state.highstate or state.apply with no specific state)
case "$func_name" in
state.highstate) ;;
state.apply)
local load_check
load_check=$(timeout 2 strings "$load_file" 2>/dev/null || true)
if echo "$load_check" | grep -qE '\b[a-z_]+\.(sls|init)\b' 2>/dev/null; then
continue
fi
;;
*) continue ;;
esac
local jid_tail jid_prefix full_jid
jid_tail=$(basename "$job_dir")
jid_prefix=$(basename "$(dirname "$job_dir")")
full_jid="${jid_prefix}${jid_tail}"
local minion_dir
for minion_dir in "$job_dir"/*/; do
[ -d "$minion_dir" ] || continue
local minion_name
minion_name=$(basename "$minion_dir")
# Only keep the most recent highstate per minion (higher JID = more recent)
if [ -n "${minion_jid[$minion_name]+x}" ]; then
if [[ "$full_jid" < "${minion_jid[$minion_name]}" ]]; then
continue
fi
fi
if [ -f "$minion_dir/return.p" ]; then
local ret_content
ret_content=$(timeout 2 strings "$minion_dir/return.p" 2>/dev/null || true)
local succeeded=0 failed=0 changed=0
succeeded=$(echo "$ret_content" | grep -ciE 'Result.*True' 2>/dev/null || true)
failed=$(echo "$ret_content" | grep -ciE 'Result.*False' 2>/dev/null || true)
changed=$(echo "$ret_content" | grep -ciE 'Changed:.*True' 2>/dev/null || true)
minion_succeeded["$minion_name"]=$succeeded
minion_failed["$minion_name"]=$failed
minion_changed["$minion_name"]=$changed
minion_jid["$minion_name"]=$full_jid
fi
done
done <<< "$jid_dirs"
local all_minions
all_minions=$(printf '%s\n' "${!minion_succeeded[@]}" | sort -u)
while IFS= read -r minion; do
[ -z "$minion" ] && continue
echo "salt_master_highstate_detail{minion=\"${minion}\",result=\"succeeded\"} ${minion_succeeded[$minion]:-0}"
echo "salt_master_highstate_detail{minion=\"${minion}\",result=\"failed\"} ${minion_failed[$minion]:-0}"
echo "salt_master_highstate_detail{minion=\"${minion}\",result=\"changed\"} ${minion_changed[$minion]:-0}"
done <<< "$all_minions"
}
# ---------------------------------------------------------------------------
# Key metrics
# ---------------------------------------------------------------------------
@@ -1238,6 +1342,12 @@ EOF
echo "salt_master_highstate_jobs_24h 0"
fi
# Per-minion highstate detail (succeeded/failed/changed from most recent run)
echo ""
echo "# HELP salt_master_highstate_detail Per-minion highstate state counts from last run"
echo "# TYPE salt_master_highstate_detail gauge"
generate_highstate_detail_metrics
cat <<EOF
# HELP salt_master_scrape_timestamp_seconds Unix timestamp of metric generation