I've had to swear and curse too much to get this up and running. Google turned out nada so I'm hoping this will help some who'll struggle with the same problem. I wanted Net-SNMP on Windows to start automatically and handle some poll requests by having it processed by an external script. The commands below register the Cygwin binaries for Net-SNMP as a service (adding a number of parameters for configuration purposes).
cygrunsrv --install "Net-SNMP Agent" --path /usr/local/sbin/snmpd.exe --args "-f -c c:/cygwin/usr/local/share/snmp/snmpd.conf -C -Lf c:/cygwin/var/log/snmpd.log tcp:16100,udp:16100" --desc "Net-SNMP Service" --type auto --dep Tcpip --shutdown -e"SNMPCONFPATH=C:/cygwin/usr/local/share/snmp" cygrunsrv --install "Net-SNMP Trap Agent" --path /usr/local/sbin/snmptrapd.exe --args "-f -c c:/cygwin/usr/local/share/snmp/snmptrapd.conf -Lf c:\cygwin\var\log\snmptrapd.log tcp:16200,udp:16200" --desc "Net-SNMP Trap Service" --type auto --dep Tcpip --shutdown -e"SNMPCONFPATH=C:/cygwin/usr/local/share/snmp"I compiled Net-SNMP 5.3.0.1 from scratch on Cygwin since the 5.1.3.1 on Win32 didn't work the way I wanted it and 5.1.3.1 on Cygwin failed to compile for me. I assume your Cygwin installation is in
C:\cygwin
(change that \ to / to stop Cygwin/bash from escaping it). The SNMPCONFPATH
is the path to snmp.conf
.
The SNMPCONFPATH
turned out to be uberimportant! /usr/local/share/snmp/snmp.conf
contains something like
persistentDir /var/net-snmp mibdirs /usr/local/share/snmp/mibs mibs +BLAHBLAH is where you put extra MIBs you want to load.