#!/bin/bash # host-night.sh — read-only: PVE task index (start, end, minutes, type, id, status) for the last 14 days; agent night lines. printf '=== pve tasks, last 14 days (local time) ===\n' cat /var/log/pve/tasks/index.1 /var/log/pve/tasks/index 2>/dev/null | perl -ne ' next unless /^UPID:[^:]+:[0-9A-Fa-f]+:[0-9A-Fa-f]+:([0-9A-Fa-f]+):([^:]+):([^:]*):[^:]+: ([0-9A-Fa-f]+) (.*)$/; my ($s,$t,$id,$e,$st)=(hex($1),$2,$3,hex($4),$5); next if $s < time-14*86400; my @a=localtime($s); my @b=localtime($e); printf "%04d-%02d-%02d %02d:%02d:%02d -> %02d:%02d:%02d %6.1f min %-12s %-8s %s\n",$a[5]+1900,$a[4]+1,$a[3],$a[2],$a[1],$a[0],$b[2],$b[1],$b[0],($e-$s)/60,$t,$id,substr($st,0,60);' | sort | grep -v -E ' (vncproxy|vncshell|spiceproxy) ' | tail -150 printf '\n=== agent: night words, 20:00 yesterday to 09:00 today (first 3 lines per message) ===\n' journalctl -u felhom-agent --since "yesterday 20:00" --until "today 09:00" --no-pager -o short-iso 2>/dev/null | grep -E 'level=(INFO|WARN|ERROR)' | grep -i -E 'backup|vzdump|verify|restore-test|prune|update|osupdate|escrow|gc|sweep|retention|offsite|window|sched' | perl -ne 'my ($m)=/msg="([^"]{0,70})/; $m//="?"; $c{$m}++; if($c{$m}<=3){ s/^(\S+) \S+ \S+ time=\S+ /$1 /; print substr($_,0,260),"\n" } END{ print "--- counts\n"; printf "%6d %s\n",$c{$_},$_ for sort keys %c }'