aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/monitoring.nix
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2023-01-08 11:08:52 +0100
committerKarel Kočí <cynerd@email.cz>2023-01-08 11:08:52 +0100
commit99c357915697b9d800523b2252850c758e2aae1d (patch)
treed296b94d4f4532f412554ce52f414bc77df67fce /nixos/modules/monitoring.nix
parente7abf8728a0fd0a77e6fa5803acd1b0c1e0682c6 (diff)
downloadnixos-personal-99c357915697b9d800523b2252850c758e2aae1d.tar.gz
nixos-personal-99c357915697b9d800523b2252850c758e2aae1d.tar.bz2
nixos-personal-99c357915697b9d800523b2252850c758e2aae1d.zip
nixos/monitoring: expand monitoring
Diffstat (limited to 'nixos/modules/monitoring.nix')
-rw-r--r--nixos/modules/monitoring.nix61
1 files changed, 43 insertions, 18 deletions
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];
})
+
];
}