[NCLUG] regex for snmp

Mike Loseke mike at verinet.com
Wed Nov 21 09:59:13 MST 2001


Thus spake mike cullerton:
> hey folks, 
> 
>  hope everyone is having a great week. thanksgiving is my favorite holiday.
> there's no avoiding it, this one is definitely about the food!
> 
>  anyway, i'm reinventing the wheel here, writing some little functions to
> help with snmp calls and i'm having some regex trouble. i'm trying to parse
> the results i get from an snmpwalk and break it up into the individual MIB
> elements. the output i receive is just one big long string.
> 
> 
> so, i would like to break up
> 
>   system.sysName.0 = gw system.sysLocation.0 = fort collins

 How are you getting all your info on one line? snmpwalk for me dumps one
entry per line (to STDOUT anyway).

 Ideers: you could (assuming reading one line at a time) dump everything
into a hash then loop around inside the hash.

 You sould also use the SNMP module for perl to do queries on a particular
string - much faster to grab a few known strings than to do an snmpwalk.
Dumping the whole MIB can take time on busy routers whereas queries are
much faster. I have several jobs that query machines and routers (average 2
queries per machine, up to 200 machines per job, average run is under a
minute).

 Whatya doin? huh? huh? :-) Pre-turkey day at work, looking for something
to do to pass the time.

-- 
                  | We all enter this world in the same way: naked;
   Mike Loseke    | screaming; soaked in blood. But if you live
 mike at verinet.com | your life right, that kind of thing doesn't
                  | have to stop there.               -- Dana Gould



More information about the NCLUG mailing list