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