track smartd with telegraf

This commit is contained in:
Ingolf Wagner 2023-05-15 09:30:42 +02:00
parent 5db34b518a
commit 209867b501
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
3 changed files with 32 additions and 3 deletions

View file

@ -30,6 +30,7 @@
./prometheus.nix ./prometheus.nix
./grafana.nix ./grafana.nix
./telegraf.nix ./telegraf.nix
./telegraf-smart.nix
#./home-display.nix #./home-display.nix
@ -86,7 +87,6 @@
#}; #};
services.printing.enable = false; services.printing.enable = false;
services.smartd.enable = true;
#home-manager.users.mailUser.home.stateVersion = "22.11"; #home-manager.users.mailUser.home.stateVersion = "22.11";

View file

@ -0,0 +1,28 @@
{ pkgs, ... }:
{
systemd.services.telegraf.path = [ pkgs.smartmontools pkgs.nvme-cli "/run/wrappers" ];
environment.systemPackages = [ pkgs.smartmontools pkgs.nvme-cli ];
services.telegraf = {
enable = true;
extraConfig.inputs.smart = {
attributes = true;
use_sudo = true;
};
};
services.smartd.enable = true;
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
'';
}

View file

@ -1,4 +1,4 @@
{ pkgs, ... }: { config, pkgs, ... }:
let let
urls = [ urls = [
{ url = "https://bitwarden.ingolf-wagner.de"; path = ""; } { url = "https://bitwarden.ingolf-wagner.de"; path = ""; }
@ -24,6 +24,7 @@ in
inputs = { inputs = {
cpu = { }; cpu = { };
diskio = { }; diskio = { };
smart.attributes = true;
x509_cert = [{ x509_cert = [{
sources = (map (url: "${url.url}:443") urls); sources = (map (url: "${url.url}:443") urls);
interval = "30m"; # agent.interval = "10s" is default interval = "30m"; # agent.interval = "10s" is default
@ -49,7 +50,7 @@ in
targets = [ "localhost:9273" ]; targets = [ "localhost:9273" ];
labels = { labels = {
service = "telegraf"; service = "telegraf";
server = "pepe"; server = config.networking.hostName;
}; };
}]; }];
} }