{ pkgs, ... }: let domaine = "nyanlout.re"; in { services = { smartd = { enable = true; defaults.monitored = "-a -o on -s (S/../.././02|L/../15/./02)"; notifications.mail = { enable = true; recipient = "paul@nyanlout.re"; }; }; influxdb = { enable = true; dataDir = "/var/db/influxdb"; }; telegraf = { enable = true; extraConfig = { agent = { # Mitigation for periodic high load average # https://github.com/influxdata/telegraf/issues/3465 collection_jitter = "5s"; }; inputs = { zfs = { poolMetrics = true; }; net = { }; netstat = { }; cpu = { totalcpu = true; }; kernel = { }; mem = { }; processes = { }; system = { }; disk = { }; cgroup = [ { paths = [ "/sys/fs/cgroup/system.slice/*" ]; files = [ "memory.current" "cpu.stat" ]; } ]; ipmi_sensor = { path = "${pkgs.ipmitool}/bin/ipmitool"; }; smart = { path = "${pkgs.writeShellScriptBin "smartctl" "/run/wrappers/bin/sudo ${pkgs.smartmontools}/bin/smartctl $@"}/bin/smartctl"; }; exec = [ { name_suffix = "_python_zpool"; commands = [ "${pkgs.zfs}/bin/zpool list --json --json-int" ]; data_format = "json"; json_query = "pools.@values.#.{NAME:name,STATE:state,ALLOC:properties.allocated.value,CAP:properties.capacity.value,DEDUP:properties.dedupratio.value,FRAG:properties.fragmentation.value,FREE:properties.free.value,HEALTH:properties.health.value,SIZE:properties.size.value}"; json_string_fields = ["STATE", "DEDUP", "HEALTH"]; tag_keys = [ "NAME" ]; } ]; }; outputs = { influxdb = { database = "telegraf"; urls = [ "http://localhost:8086" ]; }; }; }; }; udev.extraRules = '' KERNEL=="ipmi*", MODE="660", OWNER="telegraf" ''; grafana = { enable = true; dataDir = "/var/lib/grafana"; settings = { server = { http_addr = "127.0.0.1"; root_url = "https://grafana.${domaine}"; }; smtp = { enabled = true; from_address = "grafana@${domaine}"; skip_verify = true; }; auth = { disable_signout_menu = true; }; "auth.basic" = { enabled = false; }; "auth.proxy" = { enabled = true; header_name = "X-WEBAUTH-USER"; }; }; }; zfs.zed.settings = { ZED_EMAIL_ADDR = [ "paul@nyanlout.re" ]; ZED_NOTIFY_VERBOSE = true; }; }; systemd.services.influxdb.serviceConfig = { TimeoutStartSec = "10min"; }; security.sudo.extraRules = [ { commands = [ { command = "${pkgs.smartmontools}/bin/smartctl"; options = [ "NOPASSWD" ]; } ]; users = [ "telegraf" ]; } ]; }