From 9963fd814e447118efb1786284be4c1d74927820 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 13 Mar 2021 15:21:14 -0500 Subject: Valheim server monitoring --- modules/valheim.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/valheim.nix b/modules/valheim.nix index a151075..f915276 100644 --- a/modules/valheim.nix +++ b/modules/valheim.nix @@ -48,5 +48,22 @@ in steam-run ./valheim_server.x86_64 -name "doomsday" -port 3400 -world "doomsday" -password "$(cat ${statePath}/password.txt)" -savedir ${statePath} -nographics -batchmode ''; }; + + systemd.services.valheim-server-prober = { + description = "Collect metrics for valheim-server"; + startAt = "*:0/5"; + path = with pkgs; [ moreutils systemd gnugrep coreutils ]; + script = '' + systemctl show valheim-server | \ + grep -E 'IPIngress|IpEgress|CPUUsage' | \ + tr '=' ' ' | { + while read k v; do + echo "# TYPE $k counter" + echo "systemd_$k{unit='valheim-server.service'} $v"; + done + } | \ + sponge ${config.orbekk.monitoring-server.textFileDir}/valheim_server.prom + ''; + }; }; } -- cgit v1.2.3