diff --git a/nixos/modules/services/monitoring/telegraf.nix b/nixos/modules/services/monitoring/telegraf.nix index 8c51a2838e05..dfff80e1bac2 100644 --- a/nixos/modules/services/monitoring/telegraf.nix +++ b/nixos/modules/services/monitoring/telegraf.nix @@ -61,7 +61,8 @@ in { wantedBy = [ "multi-user.target" ]; wants = [ "network-online.target" ]; after = [ "network-online.target" ]; - path = lib.optional (config.services.telegraf.extraConfig.inputs ? procstat) pkgs.procps; + path = lib.optional (config.services.telegraf.extraConfig.inputs ? procstat) pkgs.procps + ++ lib.optional (config.services.telegraf.extraConfig.inputs ? ping) pkgs.iputils; serviceConfig = { EnvironmentFile = config.services.telegraf.environmentFiles; ExecStartPre = lib.optional (config.services.telegraf.environmentFiles != []) diff --git a/nixos/tests/telegraf.nix b/nixos/tests/telegraf.nix index c3cdb1645213..2ccad7af3f55 100644 --- a/nixos/tests/telegraf.nix +++ b/nixos/tests/telegraf.nix @@ -19,6 +19,12 @@ import ./make-test-python.nix ({ pkgs, ...} : { timeout = "5s"; data_format = "influx"; }; + inputs.ping = { + urls = ["127.0.0.1"]; + count = 4; + interval = "10s"; + timeout = 1.0; + }; outputs.file.files = ["/tmp/metrics.out"]; outputs.file.data_format = "influx"; }; @@ -29,5 +35,6 @@ import ./make-test-python.nix ({ pkgs, ...} : { machine.wait_for_unit("telegraf.service") machine.wait_until_succeeds("grep -q example /tmp/metrics.out") + machine.wait_until_succeeds("grep -q ping /tmp/metrics.out") ''; })