1import ./make-test-python.nix (
2 { pkgs, ... }:
3 {
4 name = "collectd";
5 meta = { };
6
7 nodes.machine =
8 { pkgs, lib, ... }:
9
10 {
11 services.collectd = {
12 enable = true;
13 extraConfig = lib.mkBefore ''
14 Interval 30
15 '';
16 plugins = {
17 rrdtool = ''
18 DataDir "/var/lib/collectd/rrd"
19 '';
20 load = "";
21 };
22 };
23 environment.systemPackages = [ pkgs.rrdtool ];
24 };
25
26 testScript = ''
27 machine.wait_for_unit("collectd.service")
28 hostname = machine.succeed("hostname").strip()
29 file = f"/var/lib/collectd/rrd/{hostname}/load/load.rrd"
30 machine.wait_for_file(file);
31 machine.succeed(f"rrdinfo {file} | logger")
32 # check that this file contains a shortterm metric
33 machine.succeed(f"rrdinfo {file} | grep -F 'ds[shortterm].min = '")
34 # check that interval was set before the plugins
35 machine.succeed(f"rrdinfo {file} | grep -F 'step = 30'")
36 # check that there are frequent updates
37 machine.succeed(f"cp {file} before")
38 machine.wait_until_fails(f"cmp before {file}")
39 '';
40 }
41)