capture_cd.sh used $B inside a quoted heredoc and never exported B, so the capture shell expanded $B to empty and every C+D screenshot showed /bin/sh: 1: /<tool>: not found. Fixed capture_one.py (prepends bin/ to PATH) and capture_cd.sh (bare names + exported PATH); new tools/regen_shots.py regenerates with a verification gate that rejects shell failures and keeps the old PNG on failure. All 310 screenshots regenerated, prompts now show the command as the user types it. Also fixed netusage --today misleading message with a single snapshot (needs two for deltas) and added __pycache__/ to .gitignore. Full suite 310/310; all 311 README/article examples audited (310 ok, 1 false positive from the marker matching netusage:).
96 lines
3.0 KiB
Bash
Executable File
96 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Capture screenshots for util_box 051-100 (slices C+D) on hot_dallas.
|
|
# Runs captures in parallel batches of 3. Logs to screenshots/LOG-C-D.txt
|
|
cd /root/fileutils || exit 1
|
|
export PATH="/root/fileutils/bin:$PATH" # bare tool names resolve; $B was never exported (bug: $B expanded to empty in the capture shell)
|
|
LOG=/root/fileutils/screenshots/LOG-C-D.txt
|
|
: > "$LOG"
|
|
|
|
run_one() {
|
|
local name="$1"; shift
|
|
local cmd="$1"
|
|
local wd="/tmp/shot-$name"
|
|
mkdir -p "$wd"
|
|
python3 /root/fileutils/tools/capture_one.py "$name" "$cmd" "$wd" "/root/fileutils/screenshots/$name.png" >/dev/null 2>&1
|
|
local rc=$?
|
|
local png="/root/fileutils/screenshots/$name.png"
|
|
if [ $rc -eq 0 ] && [ -s "$png" ] && python3 -c "from PIL import Image; Image.open('$png').verify()" 2>/dev/null; then
|
|
echo "$name | $cmd | ok" >> "$LOG"
|
|
else
|
|
# retry once with --help
|
|
python3 /root/fileutils/tools/capture_one.py "$name" "/root/fileutils/bin/$name --help" "$wd" "$png" >/dev/null 2>&1
|
|
if [ -s "$png" ] && python3 -c "from PIL import Image; Image.open('$png').verify()" 2>/dev/null; then
|
|
echo "$name | $cmd | fallback-to-help" >> "$LOG"
|
|
else
|
|
echo "$name | $cmd | failed" >> "$LOG"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# name|command (one per line)
|
|
JOBS=$(cat <<'JOBS_EOF'
|
|
cpugraph|cpugraph --frames 2 --interval 0.2
|
|
memtop|memtop -n 5
|
|
proctree|proctree --max-depth 2
|
|
loadhist|loadhist --selftest
|
|
swapwatch|swapwatch -n 5
|
|
zombiefind|zombiefind
|
|
fdleak|fdleak -n 5
|
|
threadcount|threadcount -n 5
|
|
bootlog|bootlog
|
|
cputemp|cputemp
|
|
fanwatch|fanwatch
|
|
prochist|prochist --pid 1 --interval 0.2 --samples 3
|
|
nicewatch|nicewatch
|
|
oomscore|oomscore -n 5
|
|
memfrag|memfrag
|
|
pressure|pressure
|
|
schedtop|schedtop --interval 0.2
|
|
cpufreq|cpufreq
|
|
sysnap|sysnap
|
|
watchdog|watchdog --cmd "sleep 0.5" --interval 0.2 --checks 5
|
|
prockill|prockill nosuchpattern12345
|
|
memmap|memmap 1
|
|
iowait|iowait --interval 0.2
|
|
topdisk|topdisk -n 5 --interval 0.2
|
|
kernellog|kernellog -n 10
|
|
netgraph|netgraph -n 2 -i 0.2
|
|
nettop|nettop --once -n 5
|
|
portscan|portscan
|
|
portwatch|portwatch 127.0.0.1 22 -i 0.2 -t 1
|
|
dnstime|dnstime -n 1 localhost example.com
|
|
pingraph|pingraph -c 3 -i 0.2 127.0.0.1
|
|
conntrack|conntrack
|
|
bandwidth|bandwidth -i 0.2
|
|
socklist|socklist
|
|
wifisignal|wifisignal
|
|
ipinfo|ipinfo
|
|
latency|latency -n 1 -p 22 127.0.0.1 localhost
|
|
nettrace|nettrace 127.0.0.1
|
|
portfree|portfree 8000 8010
|
|
connlog|connlog -i 0.2 -t 1
|
|
dnsleak|dnsleak
|
|
netusage|netusage --snapshot --cache-dir /tmp/shot-netusage/cache && netusage --today --cache-dir /tmp/shot-netusage/cache
|
|
sshtest|sshtest 127.0.0.1 22 --timeout 2
|
|
httpcode|httpcode https://example.com --timeout 5
|
|
certcheck|certcheck example.com 443
|
|
netblock|netblock
|
|
multicast|multicast
|
|
arpwatch|arpwatch
|
|
netdown|netdown
|
|
trafficlog|trafficlog --file /tmp/shot-trafficlog/t.csv --once && trafficlog --file /tmp/shot-trafficlog/t.csv --today
|
|
JOBS_EOF
|
|
)
|
|
|
|
count=0
|
|
while IFS='|' read -r name cmd; do
|
|
[ -z "$name" ] && continue
|
|
run_one "$name" "$cmd" &
|
|
count=$((count+1))
|
|
if [ $((count % 3)) -eq 0 ]; then wait; fi
|
|
done <<< "$JOBS"
|
|
wait
|
|
echo "DONE"
|
|
wc -l "$LOG"
|
|
cat "$LOG"
|