- #Python snmp trap receiver install#
- #Python snmp trap receiver manual#
- #Python snmp trap receiver Offline#
I created the /usr/local/bin/snmp/snmpdisco.sh file with just the following in it, echoing the results to a text file so I could try to make sense of it: cd /usr/local/binĮcho trap: $1 $host $ip $vars >/var/log/snmptest.logīe sure to make it executable: sudo chmod +x snmpdisco.sh Once I could see the OID that was being triggered from the connection/disconnection, I could add the capture to the conf file: The key to this whole process is that last line in the nf file: the traphandle. NET-SNMP version 5.7.2.1 AgentX subagent connectedĪnd what I got was a bit of a mess (this is from a connection, not disconnection): NET-SNMP version 5.7.2.1 So I manually ran snmptrapd from the command line, just to watch what came through: >sudo snmptrapd -f -Lo -c /etc/snmp/nf The most important part was finding the exact OID that was being tripped when that particular port on the switch disconnected. I could probably get away with just the execute for the WLDLifesnmp community, but it works so I left it. "just enough to be dangerous" so I left the log and net in the community. #added the following for my custom communityĪuthCommunity log,execute,net WLDLifesnmpįull disclosure: I know next to nothing about snmp in a large sense.
#Python snmp trap receiver manual#
# PLEASE: read the nf(5) manual page as well! All other lines are configuration commands for the agent. # All lines beginning with a '#' are comments and are intended for you
# When the snmptrapd agent starts up, this is where it will look for it. # This file is intended to only be an example. # An example configuration file for configuring the Net-SNMP snmptrapd The above installs everything I needed, (maybe even more than I needed, not sure) and the next step was to tweak the default nf file in /etc/snmp/ # /etc/snmp/nf
#Python snmp trap receiver install#
On the Pi: sudo apt-get install snmptrapd So I configured the switch to kick out an snmptrap packet to the IP Address of my Raspberry Pi, gave it a custom community ID of WLDLifesnmp, and just turned on the 'link down' notification in the management interface of the switch.
Of course, I immediately thought "Sounds like a Raspberry Pi project!"
#Python snmp trap receiver Offline#
(It's for a wildlife camera that I have a long ethernet cable to, and I want to know immediately if it is ever stolen or drops offline or whatever.) My managed switch has quite a lot of capabilities, but what it doesn't have is the ability to email me when one of my network drops disconnects. (I also had one heck of a time googling any information on the hurdles I had to face, so while I'm looking for suggestions on cleaning this up, I also hope this may be of help to others who are trying to do the same sort of thing)
I've got a fun little problem that I have hacked together a solution for, but I'm thinking there's probably a more elegant way of going about it.