Last active
December 16, 2015 11:28
-
-
Save q1x/f2a4c0942d29bd47244e to your computer and use it in GitHub Desktop.
Discoveries
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/bash | |
# | |
# This script discovers only interfaces with Admin status "up". | |
# | |
COMMUNITY="$1" | |
IP="$2" | |
# Set ifDescr tree | |
IFDESC=".1.3.6.1.2.1.2.2.1.2" | |
# Set ifAdminStatus tree | |
IFADMINSTATUS=".1.3.6.1.2.1.2.2.1.7" | |
# csvtolld location | |
CSVTOLLD=/opt/zabbix/csv-to-lld.py | |
# Disable mibs to save time | |
export MIBS= | |
# Walk IFDESC tree | |
discover () { | |
echo "SNMPINDEX SNMPVALUE" | |
for INDEX in $(snmpwalk -On -v 2c -c "$COMMUNITY" "$IP" "$IFADMINSTATUS" | awk '/ 1$/{print $1}' | sed "s/$IFADMINSTATUS\.//"); do | |
NAME=$(snmpget -On -v 2c -c "$COMMUNITY" "$IP" "$IFDESC.$INDEX" | awk '{print $4}' | tr -d \") | |
echo "$INDEX $NAME" | |
done | |
} | |
discover | $CSVTOLLD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment