grafana: re-organize
This commit is contained in:
38
services/grafana/intel-gpu-collector.nix
Normal file
38
services/grafana/intel-gpu-collector.nix
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
textfileDir = "/var/lib/prometheus-node-exporter-textfiles";
|
||||
|
||||
intelGpuCollector = pkgs.writeShellApplication {
|
||||
name = "intel-gpu-collector";
|
||||
runtimeInputs = with pkgs; [
|
||||
python3
|
||||
intel-gpu-tools
|
||||
];
|
||||
text = ''
|
||||
exec python3 ${./intel-gpu-collector.py}
|
||||
'';
|
||||
};
|
||||
in
|
||||
lib.mkIf config.services.grafana.enable {
|
||||
systemd.services.intel-gpu-collector = {
|
||||
description = "Collect Intel GPU metrics for Prometheus";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = lib.getExe intelGpuCollector;
|
||||
};
|
||||
environment.TEXTFILE = "${textfileDir}/intel-gpu.prom";
|
||||
};
|
||||
|
||||
systemd.timers.intel-gpu-collector = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "*:*:0/30";
|
||||
RandomizedDelaySec = "10s";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user