Collect RSS groups, top processes, and loadavg from inside each podman container (not host /proc), merge into performance.memory, show compact labels with cgroup limits and byte tooltips, and cover this in the test suite.
68 lines
3 KiB
Bash
Executable file
68 lines
3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Install central landing-stats collector as hernani user systemd timer.
|
|
#
|
|
# On koopa:
|
|
# cd ~/src/koopa/koopa-admin-log
|
|
# ./scripts/taler-landing/install-landing-stats-host.sh
|
|
# systemctl --user start taler-landing-stats.service # one-shot now
|
|
# systemctl --user status taler-landing-stats.timer
|
|
#
|
|
# Requires: linger enabled for hernani (loginctl enable-linger hernani)
|
|
# so the timer runs without an interactive login.
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
ADMIN_LOG="${ADMIN_LOG:-$ROOT}"
|
|
SRC="$ADMIN_LOG/scripts/taler-landing"
|
|
UNIT_SRC="$ADMIN_LOG/configs/systemd/user"
|
|
|
|
BIN_DST="${HOME}/.local/bin"
|
|
LIB_DST="${HOME}/.local/lib/taler-landing"
|
|
UNIT_DST="${HOME}/.config/systemd/user"
|
|
STATE_DST="${HOME}/.local/state/taler-landing-stats"
|
|
|
|
mkdir -p "$BIN_DST" "$LIB_DST" "$UNIT_DST" "$STATE_DST"
|
|
|
|
install -m 0755 "$SRC/collect-landing-stats.sh" "$BIN_DST/collect-landing-stats.sh"
|
|
install -m 0755 "$SRC/collect_bank_stats.py" "$LIB_DST/collect_bank_stats.py"
|
|
install -m 0755 "$SRC/enrich_stats_alt.py" "$LIB_DST/enrich_stats_alt.py"
|
|
install -m 0755 "$SRC/merge_resources.py" "$LIB_DST/merge_resources.py"
|
|
install -m 0755 "$SRC/collect_container_resources.sh" "$LIB_DST/collect_container_resources.sh"
|
|
install -m 0755 "$SRC/test-landing-stats.sh" "$BIN_DST/test-landing-stats.sh" 2>/dev/null || \
|
|
install -m 0755 "$SRC/test-landing-stats.sh" "$LIB_DST/test-landing-stats.sh"
|
|
install -m 0644 "$SRC/goa_amounts.py" "$LIB_DST/goa_amounts.py"
|
|
# mem-snapshot helper lives in taler-shared (copied into containers at collect time)
|
|
if [ -f "$ADMIN_LOG/scripts/taler-shared/mem-snapshot.sh" ]; then
|
|
install -m 0644 "$ADMIN_LOG/scripts/taler-shared/mem-snapshot.sh" \
|
|
"$LIB_DST/mem-snapshot.sh"
|
|
fi
|
|
|
|
# Wrapper always uses installed lib next to itself when LIB discovery works;
|
|
# also point ADMIN_LOG for in-container script refresh.
|
|
install -m 0644 "$UNIT_SRC/taler-landing-stats.service" "$UNIT_DST/"
|
|
install -m 0644 "$UNIT_SRC/taler-landing-stats.timer" "$UNIT_DST/"
|
|
|
|
# Rewrite ExecStart to installed binary if unit uses %h path — units already do.
|
|
systemctl --user daemon-reload
|
|
systemctl --user enable --now taler-landing-stats.timer
|
|
|
|
echo "Installed (user=$(id -un)):"
|
|
echo " $BIN_DST/collect-landing-stats.sh"
|
|
echo " $LIB_DST/{collect_bank_stats,enrich_stats_alt,goa_amounts}.py"
|
|
echo " $UNIT_DST/taler-landing-stats.{service,timer} (timer enabled)"
|
|
echo " logs: $STATE_DST/"
|
|
echo
|
|
if ! loginctl show-user "$(id -un)" -p Linger 2>/dev/null | grep -q 'Linger=yes'; then
|
|
echo "NOTE: enable linger so the timer survives logout:"
|
|
echo " sudo loginctl enable-linger $(id -un)"
|
|
echo
|
|
fi
|
|
echo "Run once now:"
|
|
echo " systemctl --user start taler-landing-stats.service"
|
|
echo " journalctl --user -u taler-landing-stats.service -n 40 --no-pager"
|
|
echo
|
|
echo "Optional secrets (if not readable via podman exec bank /root/…):"
|
|
echo " mkdir -p ~/.config/taler-landing"
|
|
echo " cp …/bank-admin-password.txt ~/.config/taler-landing/"
|
|
echo " cp …/bank-explorer-password.txt ~/.config/taler-landing/"
|
|
echo " chmod 600 ~/.config/taler-landing/*"
|