Skip to content

Instantly share code, notes, and snippets.

@cleverca22

cleverca22/nix-repl

Created Feb 6, 2019
Embed
What would you like to do?
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»
{ 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
You can’t perform that action at this time.