39 lines
832 B
Nix
39 lines
832 B
Nix
{
|
|
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";
|
|
};
|
|
};
|
|
}
|