Files
felhom.eu/documentation/audits/kernel-spike-2026-10-07/tools/watch-reboot.sh
T

19 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# watch-reboot.sh <label> <ssh-target> [vmid-on-hp] — after a reboot is sent: every 3 s record ping/ssh state; for a VM,
# a console screenshot every round (~5 s) through the QEMU monitor on the HP host (screendump → PNG). Stops when ssh answers with a NEW boot id, or 6 min.
L=$1 TGT=$2 VM=${3:-}; D=/mnt/5_hdd/felhom.eu/git/felhom.eu/documentation/audits/kernel-spike-2026-10-07/$L; mkdir -p $D/shots
OLDBOOT=$(cat $D/bootid.before 2>/dev/null); t0=$(date +%s); n=0
while [ $(( $(date +%s) - t0 )) -lt 360 ]; do
s=$(( $(date +%s) - t0 ))
b=$(timeout 6 ssh -o BatchMode=yes -o ConnectTimeout=4 $TGT 'cat /proc/sys/kernel/random/boot_id; uname -r' 2>/dev/null | tr '\n' ' ')
echo "+${s}s ssh=[${b:-down}]" >> $D/watch.log
if [ -n "$VM" ]; then
ssh -o BatchMode=yes hp "printf 'screendump /tmp/felhom-shot.ppm\n' | qm monitor $VM >/dev/null 2>&1; cat /tmp/felhom-shot.ppm" > $D/shots/s.ppm 2>/dev/null \
&& python3 -c "from PIL import Image; Image.open('$D/shots/s.ppm').save('$D/shots/s$(printf %04d $s).png')" 2>/dev/null; rm -f $D/shots/s.ppm
fi
n=$((n+1))
if [ -n "$b" ] && [ "${b%% *}" != "$OLDBOOT" ]; then echo "UP after ${s}s: $b" >> $D/watch.log; break; fi
sleep 3
done
tail -1 $D/watch.log