From 408ce9363bf574796487fedfe59a4a2ff0cbb4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sat, 13 Apr 2024 12:39:31 +0200 Subject: Add monitoring script with smartctl --- flakes/private/monitoring/myplugins.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'flakes/private') diff --git a/flakes/private/monitoring/myplugins.nix b/flakes/private/monitoring/myplugins.nix index f76f2c1..bb3a383 100644 --- a/flakes/private/monitoring/myplugins.nix +++ b/flakes/private/monitoring/myplugins.nix @@ -284,6 +284,30 @@ in ]} ''; }; + smartctl = { + commands = { + check_smartctl = "$USER2$/check_smartctl -i auto -d $ARG1$"; + }; + chunk = let + smartPlugin = pkgs.fetchurl { + url = "https://www.claudiokuenzler.com/monitoring-plugins/check_smart.pl"; + sha256 = "sha256-gxGkzyycUl+I3WziKhOnZSoQjpqbPqjbunfUQxmeb7w="; + }; + in '' + cp ${smartPlugin} $out/check_smartctl + chmod +x $out/check_smartctl + patchShebangs $out + substituteInPlace $out/check_smartctl --replace "/usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/sbin" "${pkgs.smartmontools}/bin" + substituteInPlace $out/check_smartctl --replace "sudo" "${sudo}" + ''; + + sudo = _: { + commands = [ + { command = "${pkgs.smartmontools}/bin/smartctl *"; options = [ "NOPASSWD" ]; } + ]; + runAs = "root"; + }; + }; mysql = { commands = { check_mysql_replication = "${sudo} -u mysql $USER2$/check_mysql_replication \"$ARG1$\" \"$ARG2$\""; -- cgit v1.2.3