grafana: re-organize
This commit is contained in:
38
services/grafana/disk-usage-collector.nix
Normal file
38
services/grafana/disk-usage-collector.nix
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
textfileDir = "/var/lib/prometheus-node-exporter-textfiles";
|
||||
|
||||
diskUsageCollector = pkgs.writeShellApplication {
|
||||
name = "disk-usage-collector";
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils
|
||||
gawk
|
||||
config.boot.zfs.package
|
||||
util-linux # for mountpoint
|
||||
];
|
||||
text = builtins.readFile ./disk-usage-collector.sh;
|
||||
};
|
||||
in
|
||||
lib.mkIf config.services.grafana.enable {
|
||||
systemd.services.disk-usage-collector = {
|
||||
description = "Collect ZFS pool and partition usage metrics for Prometheus";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = lib.getExe diskUsageCollector;
|
||||
};
|
||||
environment.TEXTFILE = "${textfileDir}/disk-usage.prom";
|
||||
};
|
||||
|
||||
systemd.timers.disk-usage-collector = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "minutely";
|
||||
RandomizedDelaySec = "10s";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user