On Thu, Feb 23, 2006 at 05:51:24PM -0700, andrew fresh wrote: > Is it possible to get net-snmp's snmpd to return an interface > description for ifAlias[1]? If so, how?
Well, nevermind, it got my interest up so here is a way that "works". It doesn't check for bad input as well as it probably should. But the stuff that is passed in is never actually used as a shell command so although it might through some strange errors I don't think it is a security risk. However, cfgmaker from MRTG doesn't think that it should check for ifAlias because there is no Vendor returned by default and so it can't even attempt to match it. But, change cfgmaker to always query ifAlias and w00 h00 my configs now have descriptions! Anyway, mostly for the archives, here is how it ends up: add something like this into your snmpd.conf pass .1.3.6.1.2.1.31.1.1.1.18 /usr/local/libexec/ifAlias and this script in /usr/local/libexec/ifAlias --- BEGIN --- #!/bin/sh # $RedRiver: ifAlias,v 1.3 2006/02/24 03:47:59 andrew Exp $ BASE='.1.3.6.1.2.1.31.1.1.1.18' # The whitespace here for the grep needs to be a tab set -A INTERFACES `ifconfig | grep -v "^ " | sed 's/:.*$//'` if [ "$1" = "-s" ]; then #echo $* >> /tmp/passtest.log exit 0 fi REQ=$2 ID=${REQ##${BASE}.} 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=${INTERFACES[$INDEX]} echo ${BASE}.${ID} if [ "X${INTERFACE}" = "X" ]; then echo noSuchName exit 0 fi echo "string" echo `ifconfig ${INTERFACE} | grep description | \ sed -e 's/^.*description:.//'` exit 0 --- END --- l8rZ, -- andrew - ICQ# 253198 - JID: [EMAIL PROTECTED] Proud member: http://www.mad-techies.org BOFH excuse of the day: The file system is full of it