Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Created February 6, 2019 09:55
Show Gist options
  • Save cleverca22/2c187ff4f21c1f0313b1ea690c5e2717 to your computer and use it in GitHub Desktop.
Save cleverca22/2c187ff4f21c1f0313b1ea690c5e2717 to your computer and use it in GitHub Desktop.
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