diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix index bb2f85a71..2e35f9a1e 100644 --- a/pkgs/overlay.nix +++ b/pkgs/overlay.nix @@ -203,10 +203,44 @@ in { mysql = super.mariadb; - monitoring-plugins = super.monitoring-plugins.overrideAttrs(_: rec { - postInstall = '' - cp plugins-root/check_dhcp $out/bin - cp plugins-root/check_icmp $out/bin + monitoring-plugins = let + binPath = lib.makeBinPath (with self; [ + (placeholder "out") + "/run/wrappers" + coreutils + gnugrep + gnused + lm_sensors + net-snmp + procps + unixtools.ping + ]); + ping = "${self.unixtools.ping}/bin/ping"; + in + super.monitoring-plugins.overrideAttrs(_: rec { + # Taken from upstream postPatch, but with an absolute path for ping instead + # of relying on PATH. Looks like PATH doesn't apply to check_ping (it's a C + # program and not a script like other checks), so check_ping needs to + # be compiled with the full path. + postPatch = '' + substituteInPlace po/Makefile.in.in \ + --replace /bin/sh ${self.runtimeShell} + + sed -i configure.ac \ + -e 's|^DEFAULT_PATH=.*|DEFAULT_PATH=\"${binPath}\"|' + + configureFlagsArray+=( + --with-ping-command='${ping} -4 -n -U -w %d -c %d %s' + --with-ping6-command='${ping} -6 -n -U -w %d -c %d %s' + ) + ''; + + # These checks are not included by default. + # Our platform doesn't use them, maybe some customer? + # XXX: Remove in 24.05 if nobody needs it. + postInstall = (super.monitoring-plugins.postInstall or "") + '' + cp plugins-root/check_dhcp $out/bin + cp plugins-root/check_icmp $out/bin ''; }); diff --git a/tests/sensuclient.nix b/tests/sensuclient.nix index b3a7a0a65..ffc727ff7 100644 --- a/tests/sensuclient.nix +++ b/tests/sensuclient.nix @@ -74,27 +74,28 @@ in }; }; - testScript = - let - in '' - import json - machine.wait_for_unit("rabbitmq.service") - machine.wait_for_unit("prepare-rabbitmq-for-sensu.service") - machine.wait_for_unit("sensu-client.service") - machine.wait_for_open_port(3031) + testScript = '' + import json + machine.wait_for_unit("rabbitmq.service") + machine.wait_for_unit("prepare-rabbitmq-for-sensu.service") + machine.wait_for_unit("sensu-client.service") + machine.wait_for_open_port(3031) - with subtest("sensu client should respond to HTTP"): - out = machine.succeed("curl localhost:3031/brew") - assert {"response":"I'm a teapot!"} == json.loads(out) + with subtest("sensu client should respond to HTTP"): + out = machine.succeed("curl localhost:3031/brew") + assert {"response":"I'm a teapot!"} == json.loads(out) - with subtest("sensu client config should have basic checks configured"): - out = machine.succeed("sensu-client-show-config") - config = json.loads(out) - assert "disk" in config["checks"] - assert "firewall-active" in config["checks"] - assert "uptime" in config["checks"] + with subtest("sensu client config should have basic checks configured"): + out = machine.succeed("sensu-client-show-config") + config = json.loads(out) + assert "disk" in config["checks"] + assert "firewall-active" in config["checks"] + assert "uptime" in config["checks"] - with subtest("sensu client should subscribe as consumer to rabbitmq"): - machine.wait_until_succeeds("sudo -u rabbitmq rabbitmqctl list_consumers -p /sensu | grep rabbit@machine") - ''; + with subtest("sensu client should subscribe as consumer to rabbitmq"): + machine.wait_until_succeeds("sudo -u rabbitmq rabbitmqctl list_consumers -p /sensu | grep rabbit@machine") + + with subtest("check_ping should be able to ping the VM"): + machine.succeed("${pkgs.monitoring-plugins}/bin/check_ping localhost -w 200,10% -c 500,30%") + ''; })