Skip to content

Instantly share code, notes, and snippets.

@q1x
Last active December 16, 2015 11:28
Show Gist options
  • Save q1x/f2a4c0942d29bd47244e to your computer and use it in GitHub Desktop.
Save q1x/f2a4c0942d29bd47244e to your computer and use it in GitHub Desktop.
Discoveries
#!/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