I have been trying to create a simple alert of interface down status on dell s4810 switches by using NET-SNMP "traphandle". I was wondering how it could be possible to pass down notification information to the script so I could parse the text? I am able to activate the script but not pass down the notification. Perhaps there is a good python or perl module? I would be grateful for any advice or suggestion.
Asked
Active
Viewed 2,449 times
1 Answers
2
When you receive a SNMP trap, the daemon snmptrapd will forward this trap to an external program (typicaly your script).
snmptrapd will add some args (IP address, hostname, notification, OID) which will be sent in the standard input of your script.
An example of script which receive the trap, this script is from http://net-snmp.sourceforge.net/wiki/index.php/TUT:Configuring_snmptrapd:
#!/bin/sh
read host
read ip
vars=
while read oid val
do
if [ "$vars" = "" ]
then
vars="$oid = $val"
else
vars="$vars, $oid = $val"
fi
done
echo trap: $1 $host $ip $vars
This script will receive the args of the snmptrapd daemon, and will echo them . So you can add a command to export to a file to see if your configuration works fine.

Sorcha
- 1,325
- 8
- 11