depot/third_party/nixpkgs/nixos/tests/collectd.nix
Default email 893b09d324 Project import generated by Copybara.
GitOrigin-RevId: eac07edbd20ed4908b98790ba299250b5527ecdf
2021-12-24 12:21:11 +08:00

33 lines
905 B
Nix

import ./make-test-python.nix ({ pkgs, ... }: {
name = "collectd";
meta = { };
machine =
{ pkgs, ... }:
{
services.collectd = {
enable = true;
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 there are frequent updates
machine.succeed(f"cp {file} before")
machine.wait_until_fails(f"cmp before {file}")
'';
})