2020-04-24 23:36:52 +00:00
|
|
|
# This test runs netdata and checks for data via apps.plugin
|
|
|
|
|
|
|
|
import ./make-test-python.nix ({ pkgs, ...} : {
|
|
|
|
name = "netdata";
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2023-03-24 00:07:29 +00:00
|
|
|
maintainers = [ cransom raitobezarius ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
netdata =
|
|
|
|
{ pkgs, ... }:
|
|
|
|
{
|
2023-08-10 07:59:29 +00:00
|
|
|
environment.systemPackages = with pkgs; [ curl jq netdata ];
|
2020-04-24 23:36:52 +00:00
|
|
|
services.netdata.enable = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
start_all()
|
|
|
|
|
|
|
|
netdata.wait_for_unit("netdata.service")
|
|
|
|
|
|
|
|
# wait for the service to listen before sending a request
|
|
|
|
netdata.wait_for_open_port(19999)
|
|
|
|
|
|
|
|
# check if the netdata main page loads.
|
|
|
|
netdata.succeed("curl --fail http://localhost:19999/")
|
|
|
|
netdata.succeed("sleep 4")
|
|
|
|
|
|
|
|
# check if netdata can read disk ops for root owned processes.
|
|
|
|
# if > 0, successful. verifies both netdata working and
|
|
|
|
# apps.plugin has elevated capabilities.
|
2023-11-16 04:20:00 +00:00
|
|
|
url = "http://localhost:19999/api/v1/data\?chart=user.root_disk_physical_io"
|
|
|
|
filter = '[.data[range(10)][2]] | add | . < 0'
|
2020-04-24 23:36:52 +00:00
|
|
|
cmd = f"curl -s {url} | jq -e '{filter}'"
|
|
|
|
netdata.wait_until_succeeds(cmd)
|
2023-08-10 07:59:29 +00:00
|
|
|
|
|
|
|
# check if the control socket is available
|
|
|
|
netdata.succeed("sudo netdatacli ping")
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
})
|