Menu
Public repository / b6107870452cfdfe4af6d140ebac6622434956ff
AkurAI-Monitor / scripts/check-metric-contract.sh
Latest change b6107870452cfdfe4af6d140ebac6622434956ff - AKURAI-MONITOR-3 share collector metric contract by Ólafur Búi Ólafsson
#!/usr/bin/env bash
set -euo pipefail
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
# Source the same names used by the Titan push wrapper; fail if the wrapper
# drifts from the contract or if the Rust collector drops a required metric.
# shellcheck source=scripts/metric-contract.sh
source "$ROOT/scripts/metric-contract.sh"
agent=$ROOT/scripts/titan-monitor-agent
collector=$ROOT/src/collectors.rs
for name in "$METRIC_CPU_USAGE" "$METRIC_MEM_TOTAL" "$METRIC_MEM_USED" \
"$METRIC_MEM_AVAILABLE" "$METRIC_MEM_USED_PCT" "$METRIC_DISK_ROOT_TOTAL" \
"$METRIC_DISK_ROOT_USED" "$METRIC_DISK_ROOT_USED_PCT" "$METRIC_LOAD_1M" \
"$METRIC_LOAD_5M" "$METRIC_LOAD_15M" "$METRIC_UPTIME"; do
grep -Fq "$name" "$collector"
done
for variable in METRIC_CPU_USAGE METRIC_MEM_TOTAL METRIC_MEM_USED \
METRIC_MEM_AVAILABLE METRIC_MEM_USED_PCT METRIC_DISK_ROOT_TOTAL \
METRIC_DISK_ROOT_USED METRIC_DISK_ROOT_USED_PCT METRIC_LOAD_1M \
METRIC_LOAD_5M METRIC_LOAD_15M METRIC_UPTIME; do
grep -Fq "$variable" "$agent"
done
grep -Fq 'sleep 1' "$agent"
grep -Fq 'METRIC_NET_SAMPLING' "$ROOT/scripts/metric-contract.sh"
grep -Fq 'mount != "/"' "$collector" || {
echo 'Rust collector must emit the canonical root disk namespace' >&2
exit 1
}