summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2021-03-13 15:21:14 -0500
committerKjetil Orbekk <kj@orbekk.com>2021-03-13 15:21:14 -0500
commit9963fd814e447118efb1786284be4c1d74927820 (patch)
treedb2ed8f24384b7e712e43650acf0ca5e2e77699e /modules
parent930adc628cb4e2d262f392088a5dcb2f1d9d43b7 (diff)
Valheim server monitoring
Diffstat (limited to 'modules')
-rw-r--r--modules/valheim.nix17
1 files changed, 17 insertions, 0 deletions
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
+ '';
+ };
};
}