I’m digging into SNMP (Simple Network Management Protocol) to see what it offers in terms of application / server monitoring.
The specific scenario I have in mind is the monitoring of queues in MSMQ for our NServiceBus windows services. We need email alerts to be triggered if a message is moved to the error queue or if the number of items in a queue exceeds a certain threshold.
I’m working on a Windows 7 x64 laptop so the first thing I had to do was install the SNMP service (Under CP > Programs and Features).
After that was installed I had to restart the services applet and right click > Properties > Security on the SNMP Service and create a “public” community.
After this I had to download a command line tool Net-SNMP for issuing SNMP queries to test all was well.
I opted for the basic installation and uncheck all the other options.
Open a new command prompt so that it picks up the PATH variable added during installation then run the following command
snmptranslate -IR -Td IF-MIB::linkDown
See the README.txt for the correct response but if you see no errors you are in good shape.
Next download SnmpTools Follow the instructions. I opted to install the 32bit version using the regagentWow6432.reg
Restart the Microsoft SNMP Service then run the command:
snmpget -v1 -c public localhost 126.96.36.199.4.1.15
If all is well you should see:
SNMPv2-SMI::enterprises.15 = STRING: “snmptools by email@example.com”
That’s all for now but I will update this post again.
As Promised Part 2
I have made a little more progress accessing the MSMQ Performance counters
I have added the following two lines to the Counters.ini file and restarted the SNMP Service:
counter=MSMQ QueueMessages in Queueacerboticprivate$distributordatabus
Now when I issue the following snmpget query from the command line:
snmpget -v1 -c public localhost 188.8.131.52.184.108.40.206
I see the response:
SNMPv2-SMI::enterprises.15.5 = INTEGER: 2
Thus indicating there are two messages in the private$distributordatabus queue on my laptop.
The End Game
At time of writing it seems that in order to allow our SNMP monitoring software to access this OID I need to supply it with a MIB file.
The story continues…
I have found this page that talks about using a MIB editor to create such a file.
SNMP is a great way to monitor your application, but it involves a good deal of upfront investment if you don’t already have a developer on your team who is proficient. We don’t have such a developer so have decided to use the .Net framework to expose peformance counters and use WMI to monitor those counters. If the thresholds we set are exceeded we will get alerts.