Created
August 17, 2014 07:03
-
-
Save JCotton1123/f73e75b9684591c307b8 to your computer and use it in GitHub Desktop.
Parse snmp mac notification trap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
LOG_FILE=/var/log/snmp/mactrap.log | |
read host | |
read ip | |
ip=`echo $ip | cut -d"[" -f2 | cut -d"]" -f1` | |
while read oid value | |
do | |
`echo $oid | grep 'CISCO-SMI::ciscoMgmt.215.1.1.8.1.2' > /dev/null` | |
if [ $? -eq 0 ]; then | |
timestamp=`date +"%Y-%m-%d %T"` | |
val=`echo $value | cut -d"=" -f2 | tr '\"' '\0'` | |
type=`echo $val | cut -d" " -f1` | |
vlan=`echo $val | cut -d" " -f2,3` | |
mac_addr=`echo $val | cut -d" " -f4,5,6,7,8,9` | |
port=`echo $val | cut -d" " -f10,11` | |
entry=`echo "$ip|$type|$vlan|$mac_addr|$port" | tr -d ' '` | |
echo "$timestamp|$entry" >> $LOG_FILE | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment