nix/services/telegraf.nix
2023-07-05 21:04:12 +09:00

68 lines
No EOL
1.5 KiB
Nix

{ config, pkgs, hostname, ... }: {
# Telegraf Monitoring
sops.secrets.telegraf-token = {
owner = "telegraf";
sopsFile = ../secrets/secrets.yaml;
restartUnits = [ "telegraf.service" ];
};
# Install the package
environment.systemPackages = with pkgs; [
lm_sensors
telegraf
fail2ban
];
systemd.services.telegraf = {
path = [
sensors
fail2ban-client
];
};
# Configure the package:
services.telegraf = {
enable = true;
environmentFiles = [ /run/secrets/telegraf-token ];
extraConfig = {
outputs = {
influxdb_v2 = {
urls = [ "https://influx.sysctl.io/" ];
token = "$TELEGRAF_TOKEN";
organization = "default";
bucket = "telegrafdb";
http_headers = { Authorization = "Token $TELEGRAF_TOKEN"; };
};
};
inputs = {
cpu = {
percpu = true;
totalcpu = true;
collect_cpu_time = false;
report_active = false;
};
disk = {
ignore_fs = ["tmpfs" "devtmpfs" "devfs" "iso9660" "overlay" "aufs" "squashfs"];
};
diskio = {};
kernel = {};
mem = {};
processes = {};
swap = {};
system = {};
fail2ban = {};
hddtemp = {};
intel_powerstat = {};
net = {};
nvidia_smi = {};
sensors = {};
smart = {
timeout = "30s";
};
temp = {};
wireless = {};
};
};
};
}