IfAlias descriptions on Debian/Ubuntu
From Observium
If you would like to put descriptions on your interfaces on Debian GNU/Linux or one of its derivatives, you can use the following script:
#!/bin/bash
# ifAlias for Debian GNU/Linux
# (c) 2010, Tom Laermans, www.observium.org
#
BASE='.1.3.6.1.2.1.31.1.1.1.18'
declare -a INTERFACES=($(ip l|grep mtu|cut -d: -f2|sed s/\ //g))
REQ=$2
ID=$(echo ${REQ##${BASE}.} |cut -d: -f1)
if [ "X${REQ}" = "X${BASE}" ]; then
ID=0
fi
if [ "$1" = "-n" ]; then
INDEX=$ID
ID=$(( $ID + 1 ))
else
INDEX=$(( $ID - 1 ))
fi
if [ "X$ID" = "X" ] || [ "X$ID" = "X0" ] || [ "X$ID" = "X-1" ]; then
exit 0
fi
INTERFACE=$(echo ${INTERFACES[$INDEX]}|cut -d@ -f1)
echo ${BASE}.${ID}
if [ "X${INTERFACE}" = "X" ]; then
echo noSuchName
exit 0
fi
echo "string"
echo $(grep "^# $INTERFACE:" /etc/network/interfaces|sed s/^\#\ $INTERFACE:\ //)
exit 0
Save it somewhere (i.e. /usr/local/lib/ifAlias), then add this into your snmpd.conf:
pass .1.3.6.1.2.1.31.1.1.1.18 /usr/local/lib/ifAlias
You can put the descriptions into /etc/network/interfaces
# eth0: Transit: YourISP Inc. Leased Line iface eth0 inet static ....
On the next poll, Observium should then pick up your descriptions. (Don't forget to restart snmpd after changing the configuration!)