mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 22:43:01 +00:00
934a337a13
We need ping to be in PATH of the service otherwise it can't ping. This commit adds it, conditional on one of the inputs being a ping task.
41 lines
1.0 KiB
Nix
41 lines
1.0 KiB
Nix
import ./make-test-python.nix ({ pkgs, ...} : {
|
|
name = "telegraf";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ mic92 ];
|
|
};
|
|
|
|
nodes.machine = { ... }: {
|
|
services.telegraf.enable = true;
|
|
services.telegraf.environmentFiles = [(pkgs.writeText "secrets" ''
|
|
SECRET=example
|
|
'')];
|
|
services.telegraf.extraConfig = {
|
|
agent.interval = "1s";
|
|
agent.flush_interval = "1s";
|
|
inputs.exec = {
|
|
commands = [
|
|
"${pkgs.runtimeShell} -c 'echo $SECRET,tag=a i=42i'"
|
|
];
|
|
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";
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
|
|
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")
|
|
'';
|
|
})
|