#!/bin/bash
# Sample host + three-container CPU/RSS from koopa (run as hernani via ssh).
# Usage (local):  ssh hernani@koopa 'bash -s' < sample-load-inside.sh
# Or:            ./sample-load-inside.sh   # if executed ON koopa as hernani
set -eu
tag="${1:-manual}"
echo "=== sample_load tag=$tag $(date -u +%FT%TZ) ==="
echo "=== loadavg ==="
cat /proc/loadavg
echo "=== mem ==="
free -h 2>/dev/null || true
echo "=== top host cpu ==="
ps -eo pid,pcpu,pmem,rss,etime,comm --sort=-pcpu 2>/dev/null | head -15
echo "=== exchange (taler-hacktivism-exchange-ansible) ==="
podman exec taler-hacktivism-exchange-ansible \
  ps -eo pid,pcpu,pmem,rss,etime,args 2>/dev/null \
  | grep -E 'taler-exchange|postgres -D|PID' | head -25 || true
echo "=== merchant (taler-hacktivism) ==="
podman exec taler-hacktivism \
  ps -eo pid,pcpu,pmem,rss,etime,args 2>/dev/null \
  | grep -E 'taler-merchant|nginx|postgres -D' | head -25 || true
echo "=== bank (taler-bank-hacktivism) ==="
podman exec taler-bank-hacktivism \
  ps -eo pid,pcpu,pmem,rss,etime,args 2>/dev/null \
  | grep -E 'java|libeufin|postgres -D' | head -15 || true
echo "=== sample_load done ==="
