pysnmp/shell

Axel Scheepers axel at axel.truedestiny.net
Tue Jun 22 08:58:36 EDT 2004


Hi All,

Python is so great. I've been creating a small set of objects to get some
stats from our adsl routers. So far it works great and fast. However, in the
shell script I created over a year ago to gather stats I do:

       mib_lp=`$snmpwalk $ip_address public
ip.ipAddrTable.ipAddrEntry.ipAdEntIf
Index 2>/dev/null | $grep " = $lan_iface" | $head -1 | $sed -E
's/^ip.ipAddrTabl
e.ipAddrEntry.ipAdEntIfIndex.(.+) = .*/\1/g'`
       if [ "$mib_lp" != "" ]; then
         lan_ip=`$snmpget $ip_address public
ip.ipAddrTable.ipAddrEntry.ipAdEntA
ddr.$mib_lp 2>/dev/null | $sed -E 's/.+IpAddress: //g'`
         lan_netmask=`$snmpget $ip_address public
ip.ipAddrTable.ipAddrEntry.ipA
dEntNetMask.$mib_lp 2>/dev/null| $sed -E 's/.+IpAddress: //g'`
       else
         lan_ip="ERROR"
         lan_netmask="ERROR"
       fi

To retrieve the lan settings for the router. I don't know the (lan)ip
address of it but do know the interface number, that's why I check for that
and then use a part of the mib to get to the netmask.

This seems to be quite difficult with pysnmp (took me half an hour to write
Router.SNMPQuery(self, noid) ;-)), so before I get started I wanted to ask
if somebody might have  better idea for this.

Thanks!
Kind regards,
Axel Scheepers





More information about the Python-list mailing list