Reputation: 490
I have to send a SNMP trap towards my monitor with a script (perl for instance, or other) when some condition is met (e.g. when memory use or disk usage rise above 80%). I never write script so I have no idea how to do that.
This little script will allow me to test my java program which catch some traps on a given port.
Upvotes: 1
Views: 7380
Reputation: 2715
If all you want is to send a trap to test your trap receiver, you don't have to write a script! You can just download and install the net-snmp command line tools from http://net-snmp.sourceforge.net/download.html The command "snmptrap" is just what you're looking for.
If you want to do this from a shell script, of course you just ahve the script call the snmptrap binary.
If you are actually writing some monitoring script in perl, I still think the easiest way is to execute the snmptrap program from the perl script. You do also have the option of using some SNMP library. I've used Net::SNMP (unrelated to net-snmp) to good effect: https://metacpan.org/pod/Net::SNMP
Upvotes: 2