Friday, December 8, 2017

Sending an SNMP trap

It's been necessary from time to time for me to send a test SNMP trap to test host monitoring, fault management and alerting systems. It's always been an ad hoc affair, full of errors, as it seems it is for a lot of Admins.

This is an occasional, but common need. SNMP is complex enough that it's not simple to generate a test trap, particularly if you have no background. Even worse, all of the websites that discuss the matter want to teach you SNMP, when all you want is the command to send a test trap to someone who cares.

Tired of not understanding the process, I invested some time and effort the latest time I needed to conduct this sort of test. Then, I scripted it so I never have to get that stuff on my hands again.

The below is tested on RedHat Linux 7.2, but should work on any Linux host with net-SNMP installed. It knows how to send a linkUp linkDown, warmStart and coldStart trap.