Created
February 6, 2019 09:55
-
-
Save cleverca22/2c187ff4f21c1f0313b1ea690c5e2717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nix-repl> eval = import <nixpkgs/nixos> { configuration = ./snmpd.nix; } | |
nix-repl> eval.config.systemd.units."snmpd.service".unit | |
«derivation /nix/store/q8nq58244hw0v04w400kzwllxwb42zrg-unit-snmpd.service.drv» |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, ... }: | |
let | |
secrets = import ./load-secrets.nix; | |
in | |
{ | |
systemd.services.snmpd = let | |
snmpconfig = pkgs.writeTextFile { | |
name = "snmpd.conf"; | |
text = '' | |
rocommunity ${secrets.snmp} | |
disk / 10000 | |
extend cputemp ${pkgs.stdenv.shell} -c "${pkgs.acpi}/bin/acpi -t|egrep -o '[0-9\.]{3,}'" | |
extend conntrack ${pkgs.stdenv.shell} -c "cat /proc/net/nf_conntrack | wc -l" | |
''; | |
}; | |
in { | |
description = "net-snmp daemon"; | |
wantedBy = [ "multi-user.target" ]; | |
serviceConfig = { | |
ExecStart = "${pkgs.net_snmp}/bin/snmpd -f -c ${snmpconfig}"; | |
KillMode = "process"; | |
Restart = "always"; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment