Switches, Hubs, and Modems
cancel
Showing results for 
Search instead for 
Did you mean: 

SNMP Walk Script Help

Michael Lyon
Frequent Advisor

SNMP Walk Script Help

I'm trying to write a [simple] script and I need some help doing it. I am looking to track unused switch ports.

What I am trying to do is this:

1. snmpget sysUPtime
2. snmpwalk ifOperstatus |grep "down"
**use awk, get the ifIndex of the results from step 2, then do:
3. snmpget ifLastChange.
**This will give me the uptime which the last state transition on an interface took place.
4. DOWNTIME=(Step1 - Step3) / 8640000

Thanks for your help!
1 REPLY
OLARU Dan
Trusted Contributor

Re: SNMP Walk Script Help

This is tricky. I'm interested in this also, and the problems I ran into are:

1. A person leaves for vacation and, for 15 days, there will be no traffic on his/her port (ifInOctets and ifOutOctets will stay constant), and ifOperStatus is "down". If in the 10-th day I need a port in that switch - do I disconnect this port? It happened to me to disconnect TopMgmt and I've got kicked around when they returned :-)

2. When a switch restarts, it zeroes all counters, including sysUpTime and interface counters.

3. People may move from one network jack to another, leaving non-zero values of if??Octets on the old port.

4. Printers with powersave feature might appear "down".

I think than we have to think statistically. One can say, at any time, with a certain confidence level (0% to 100%) that there is a probability (0 to 1) a switch port is free, based on periodic reading and interpretation of SNMP port properties.

For example, if one port showed 0 bytes traffic variation (constant non-zero if??Octets value), and it was "down" for 50 consecutive days each time we sampled it, we can say with 100% confidence that this port has a probability of 1 of being free. The value of 50 days is based on the maximum vacation time of 35 working days (7 weeks = 49 calendar days).

But people might be gone for 60 or 90 days for some training abroad... so the criteria to decide if the port is truly free must be a compozite. We might have to wait 1/4 of a year to decide in this way that a port is 100% free.

Fluke's NetTool or LinkRunner might help to reduce this time: go to the switch, unplug the patch cable from a port with no light, plug it in NetTool and see if there is a NIC at the other end.

Interestin', huh?