nixos-config/machines/chungus/telemetry/telegraf-smart.nix
Ingolf Wagner 7a6510a4e6
nix fmt
2024-08-29 08:26:04 +07:00

33 lines
763 B
Nix

{ pkgs, ... }:
{
services.smartd.enable = true;
environment.systemPackages = [
pkgs.smartmontools
pkgs.nvme-cli
];
services.telegraf.extraConfig.inputs.smart = {
attributes = true;
use_sudo = true;
};
systemd.services.telegraf.path = [
pkgs.smartmontools
pkgs.nvme-cli
"/run/wrappers"
];
security.sudo.configFile = ''
# For smartctl add the following lines:
Cmnd_Alias SMARTCTL = ${pkgs.smartmontools}/bin/smartctl
telegraf ALL=(ALL) NOPASSWD: SMARTCTL
Defaults!SMARTCTL !logfile, !syslog, !pam_session
# For nvme-cli add the following lines:
Cmnd_Alias NVME = ${pkgs.nvme-cli}/bin/nvme
telegraf ALL=(ALL) NOPASSWD: NVME
Defaults!NVME !logfile, !syslog, !pam_session
'';
}