Skip to content

Commit

Permalink
Merge branch 'fc-23.11-dev' into fc-23.11-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
dpausp committed Feb 8, 2024
2 parents ebb9bb3 + 87c00c3 commit ab0b907
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 24 deletions.
42 changes: 38 additions & 4 deletions pkgs/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
});

Expand Down
41 changes: 21 additions & 20 deletions tests/sensuclient.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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%")
'';
})

0 comments on commit ab0b907

Please sign in to comment.