3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/tests/collectd.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.1 KiB
Nix
Raw Normal View History

2021-12-22 12:00:00 +00:00
import ./make-test-python.nix ({ pkgs, ... }: {
name = "collectd";
meta = { };
2022-03-20 23:15:30 +00:00
nodes.machine =
{ pkgs, lib, ... }:
2021-12-22 12:00:00 +00:00
{
services.collectd = {
enable = true;
extraConfig = lib.mkBefore ''
Interval 30
'';
2021-12-22 12:00:00 +00:00
plugins = {
rrdtool = ''
DataDir "/var/lib/collectd/rrd"
'';
load = "";
};
};
environment.systemPackages = [ pkgs.rrdtool ];
};
testScript = ''
machine.wait_for_unit("collectd.service")
hostname = machine.succeed("hostname").strip()
file = f"/var/lib/collectd/rrd/{hostname}/load/load.rrd"
machine.wait_for_file(file);
machine.succeed(f"rrdinfo {file} | logger")
# check that this file contains a shortterm metric
machine.succeed(f"rrdinfo {file} | grep -F 'ds[shortterm].min = '")
# check that interval was set before the plugins
machine.succeed(f"rrdinfo {file} | grep -F 'step = 30'")
2021-12-22 12:00:00 +00:00
# check that there are frequent updates
machine.succeed(f"cp {file} before")
machine.wait_until_fails(f"cmp before {file}")
'';
})