nixos/prometheus-smartctl-exporter: providing the path to the binary is no longer needed

This commit is contained in:
Peter Hoeg 2024-07-29 20:53:40 +02:00
parent 0bab1a6d6e
commit c3392ad349

View File

@ -2,20 +2,23 @@
let let
cfg = config.services.prometheus.exporters.smartctl; cfg = config.services.prometheus.exporters.smartctl;
inherit (lib) mkOption types literalExpression; inherit (lib) mkOption types literalExpression;
args = lib.escapeShellArgs ([ args = lib.escapeShellArgs ([
"--web.listen-address=${cfg.listenAddress}:${toString cfg.port}" "--web.listen-address=${cfg.listenAddress}:${toString cfg.port}"
"--smartctl.path=${pkgs.smartmontools}/bin/smartctl"
"--smartctl.interval=${cfg.maxInterval}" "--smartctl.interval=${cfg.maxInterval}"
] ++ map (device: "--smartctl.device=${device}") cfg.devices ] ++ map (device: "--smartctl.device=${device}") cfg.devices
++ cfg.extraFlags); ++ cfg.extraFlags);
in {
in
{
port = 9633; port = 9633;
extraOpts = { extraOpts = {
devices = mkOption { devices = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [ ];
example = literalExpression '' example = literalExpression ''
[ "/dev/sda", "/dev/nvme0n1" ]; [ "/dev/sda", "/dev/nvme0n1" ];
''; '';
@ -24,6 +27,7 @@ in {
all disks if none given. all disks if none given.
''; '';
}; };
maxInterval = mkOption { maxInterval = mkOption {
type = types.str; type = types.str;
default = "60s"; default = "60s";
@ -50,9 +54,7 @@ in {
"block-sd rw" "block-sd rw"
"char-nvme rw" "char-nvme rw"
]; ];
ExecStart = '' ExecStart = "${pkgs.prometheus-smartctl-exporter}/bin/smartctl_exporter ${args}";
${pkgs.prometheus-smartctl-exporter}/bin/smartctl_exporter ${args}
'';
PrivateDevices = lib.mkForce false; PrivateDevices = lib.mkForce false;
ProtectProc = "invisible"; ProtectProc = "invisible";
ProcSubset = "pid"; ProcSubset = "pid";