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,022 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.
![](../../users/profiles/313242.webp)
Sorcha
- 1,315
- 8
- 11