Files
ultix/staged/ukrrs-psi-textfile.sh
T
mrcharles cba2a64d67 ultix perf/ops workbench: complete 2026-08-31 optimization pass for VM 5111
Everything for the ultix-streaming (VM 5111, pfv-tsys5) performance pass:
full report + host audit results, staged/gated configs, guest prep + host
one-shot + post-reboot-fix + netcheck lifecycle scripts, grow-root manual
runbook, rolling tracking HUD, questions v1, and the gateway boot-race
hardening units. Applied and verified live 2026-08-31; open work is
tracked in Redmine project 55 as #601-#607. [#602]

💘 Generated with Crush

Assisted-by: Crush:glm-5.2
2026-08-31 16:46:13 -05:00

40 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Per-slice + host PSI (pressure stall info) avg60 -> node_exporter textfile.
# Consumed by the existing mopac-harness prometheus; gateway may also read it.
set -u
OUT_DIR=${UKRRS_TEXTFILE_DIR:-/var/lib/node_exporter/textfile}
CGROOT=${UKRRS_CGROOT:-/sys/fs/cgroup}
mkdir -p "$OUT_DIR"
tmp=$(mktemp "$OUT_DIR/.ukrrs.XXXXXX")
some60() { # file -> prints avg60 value or nothing
awk '$1=="some"{for(i=2;i<=NF;i++) if($i ~ /^avg60=/){sub("avg60=","",$i); print $i; exit}}' "$1" 2>/dev/null
}
emit() { # name cgroup_path
local res v
for res in cpu memory io; do
[ -r "$2/$res.pressure" ] || continue
v=$(some60 "$2/$res.pressure")
[ -n "${v:-}" ] && echo "ukrrs_slice_pressure_some60{slice=\"$1\",res=\"$res\"} $v"
done
}
echo "# HELP ukrrs_slice_pressure_some60 PSI some avg60 (percent) for ukrrs slices" >>"$tmp"
echo "# TYPE ukrrs_slice_pressure_some60 gauge" >>"$tmp"
for cg in "$CGROOT"/system.slice/ukrrs-*.slice; do
[ -d "$cg" ] && emit "${cg##*/}" "$cg"
done
[ -d "$CGROOT/user.slice" ] && emit "user.slice" "$CGROOT/user.slice"
echo "# HELP ukrrs_host_pressure_some60 PSI some avg60 (percent) host-wide" >>"$tmp"
echo "# TYPE ukrrs_host_pressure_some60 gauge" >>"$tmp"
for res in cpu memory io; do
[ -r "/proc/pressure/$res" ] || continue
v=$(some60 "/proc/pressure/$res")
[ -n "${v:-}" ] && echo "ukrrs_host_pressure_some60{res=\"$res\"} $v"
done
mv "$tmp" "$OUT_DIR/ukrrs_pressure.prom"
chmod 0644 "$OUT_DIR/ukrrs_pressure.prom"