From 99c357915697b9d800523b2252850c758e2aae1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 8 Jan 2023 11:08:52 +0100 Subject: nixos/monitoring: expand monitoring --- nixos/modules/monitoring.nix | 61 +++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 18 deletions(-) (limited to 'nixos/modules/monitoring.nix') diff --git a/nixos/modules/monitoring.nix b/nixos/modules/monitoring.nix index 1f011dd..abeba2d 100644 --- a/nixos/modules/monitoring.nix +++ b/nixos/modules/monitoring.nix @@ -30,6 +30,7 @@ in { config = mkMerge [ { cynerd.monitoring.host = "errol"; } + (mkIf cnf.enable { # Telegraf configuration services.telegraf = { @@ -37,44 +38,63 @@ in { environmentFiles = ["/run/secrets/telegraf.env"]; extraConfig = { agent = {}; - outputs.influxdb_v2 = { + outputs.influxdb_v2 = [{ urls = ["http://errol:8086"]; token = "$INFLUX_TOKEN"; organization = "personal"; bucket = "monitoring"; - }; + tagdrop.source = ["bigclown"]; # See home-assistant.nix + }]; inputs = { - cpu = { + cpu = [{ percpu = true; totalcpu = true; - }; - disk = { + }]; + mem = [{}]; + swap = [{}]; + disk = [{ ignore_fs = [ "tmpfs" "devtmpfs" "devfs" "iso9660" "overlay" "aufs" "squashfs" ]; - }; - diskio = {}; - diskio = {}; - mem = {}; - net = {}; - processes = {}; - swap = {}; - system = {}; + }]; + diskio = [{}]; + net = [{}]; + system = [{}]; + processes = [{}]; + systemd_units = [{}]; + wireguard = [{}]; } // (optionalAttrs cnf.hw { - sensors = {}; - smart = {}; + sensors = [{}]; + smart = [{ + path_smartctl = "${pkgs.smartmontools}/bin/smartctl"; + use_sudo = true; + }]; + wireless = [{}]; }); }; }; - # TODO probably add this to the upstream configuration systemd.services.telegraf.path = with pkgs; [ + "/run/wrappers" ] ++ (optionals cnf.hw [ - nvme-cli lm_sensors smartmontools + lm_sensors smartmontools nvme-cli ]); + security.sudo.extraRules = [ + { + users = ["telegraf"]; + commands = [{ + command = "${pkgs.smartmontools}/bin/smartctl"; + options = ["NOPASSWD"]; + }]; + } + ]; }) + (mkIf isHost { # InfluxDB services.influxdb2.enable = mkIf isHost true; + services.telegraf.extraConfig.inputs.prometheus = { + urls = ["http://localhost:8086/metrics"]; + }; # Grafana services.grafana = mkIf isHost { enable = true; @@ -84,9 +104,14 @@ in { admin_user = "cynerd"; admin_password = "$__file{/run/secrets/grafana.admin.pass}"; }; + server = { + http_addr = ""; + http_port = 3000; + }; }; }; - + networking.firewall.allowedTCPPorts = [8086 3000]; }) + ]; } -- cgit v1.2.3