KNELPerf v2 wave 1: Ultix scheduler breakout + loop skeleton + reports (#826)
ci / audit (push) Failing after 26s
ci / audit (push) Failing after 26s
- scheduler/: day/night engine (conf-driven redesign), psi/perfsnap collectors, proxmox-ctl, systemd timer templates — ported from ~/projects/ultix per the breakout map in scheduler/README.md - loop/: perf-loop driver (baseline/audit/tweak/rebaseline), cpu-bench (new CPU leg), baseline-diff (tolerance compare) — smoke-tested locally - docs/ARCHITECTURE.md: full program design (loop, resource groups, VM/spindle balancing, k8s-vs-Slurm, beszel+RAPL/iDRAC telemetry spine, workload classes, solar/HA + two-site power economics) - docs/report-amt-power-telemetry.md + docs/report-moonlight-desktop.md Redmine: https://projects.knownelement.com/issues/826#note-2
This commit is contained in:
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
# KNELPerf perfsnap — periodic /proc+cgroupfs snapshot collector.
|
||||
# Ported from ultix staged/reachableceo-perfsnap.sh (#826); generalizations:
|
||||
# - watched cgroups and interfaces are env/conf-driven lists (no baked-in
|
||||
# user ids or NIC names)
|
||||
# - log dir env-driven; same pipe-delimited format for awk analysis
|
||||
#
|
||||
# Env (or /etc/knelperf/perfsnap.conf):
|
||||
# KNELPERF_PERF_LOGDIR default /var/log/knelperf-perf
|
||||
# KNELPERF_SNAP_CGROUPS space-separated "label:/sys/fs/cgroup/path" list
|
||||
# KNELPERF_SNAP_IFACES space-separated interface names
|
||||
# Fields (snap.log): ts|l1|l5|l15|run|blocked|memavail_kb|psi_cpu|psi_mem|
|
||||
# psi_io|<cgroup usage_usec per label>|<iface rx tx per label>
|
||||
# psi_* = avg60 "some" percentages. *_usec = cgroup cpu.stat usage_usec
|
||||
# (cumulative; analyze deltas).
|
||||
set -u
|
||||
CONF=/etc/knelperf/perfsnap.conf
|
||||
[ -r "$CONF" ] && . "$CONF"
|
||||
LOGDIR=${KNELPERF_PERF_LOGDIR:-/var/log/knelperf-perf}
|
||||
SNAP_CGROUPS=${KNELPERF_SNAP_CGROUPS:-}
|
||||
SNAP_IFACES=${KNELPERF_SNAP_IFACES:-}
|
||||
mkdir -p "$LOGDIR"
|
||||
ts=$(date +%s)
|
||||
|
||||
read -r l1 l5 l15 _ < /proc/loadavg
|
||||
run=$(awk '/procs_running/{print $2}' /proc/stat)
|
||||
blocked=$(awk '/procs_blocked/{print $2}' /proc/stat)
|
||||
memavail=$(awk '/MemAvailable/{print $2}' /proc/meminfo)
|
||||
|
||||
psi() { awk '$1=="some"{for(i=2;i<=NF;i++) if($i ~ /^avg60=/){sub("avg60=","",$i); print $i; exit}}' "/proc/pressure/$1" 2>/dev/null || echo 0; }
|
||||
|
||||
line="$ts|$l1|$l5|$l15|$run|$blocked|$memavail|$(psi cpu)|$(psi memory)|$(psi io)"
|
||||
|
||||
cgusec() { awk '/^usage_usec/{print $2}' "$1/cpu.stat" 2>/dev/null || echo 0; }
|
||||
for spec in $SNAP_CGROUPS; do
|
||||
line="$line|$(cgusec "${spec#*:}")"
|
||||
done
|
||||
|
||||
nd() { awk -v i="$1" '$1==i":":{print $2" "$10}' /proc/net/dev 2>/dev/null || echo "0 0"; }
|
||||
for ifc in $SNAP_IFACES; do
|
||||
read -r rx tx <<< "$(nd "$ifc")"
|
||||
line="$line|$rx|$tx"
|
||||
done
|
||||
|
||||
echo "$line" >> "$LOGDIR/snap.log"
|
||||
|
||||
ps -eo pcpu,pid,comm --sort=-pcpu --no-headers | head -5 \
|
||||
| awk -v t="$ts" '{print t"|"$1"|"$2"|"$3}' >> "$LOGDIR/procs.log"
|
||||
|
||||
# retention: 14 days; rotate anything over 50MB
|
||||
find "$LOGDIR" -name '*.log' -mtime +14 -delete 2>/dev/null
|
||||
for f in "$LOGDIR"/*.log; do
|
||||
[ "$(wc -c <"$f" 2>/dev/null || echo 0)" -gt 52428800 ] && mv "$f" "$f.1"
|
||||
done
|
||||
exit 0
|
||||
Reference in New Issue
Block a user