[mrtg] Re: IP Address brand router querying

Mike Mitchell Mike.Mitchell at sas.com
Thu Jun 15 16:59:40 MEST 2000


If you already have MRTG, you don't really need an snmpwalk
executable laying around for this.  You can do it all in
a simple perl script using the SNMP_session.pm, BER.pm, and
SNMP_util.pm modules shipped with MRTG.  Try this perl script:

#! /usr/bin/perl
use SNMP_util;
while(<>) {
   chomp;   
   printf "$_ %s\n", &snmpget($_, "sysDescr");
}

This should work if it is executed out of the MRTG bin directory (where
SNMP_util.pm lives).  If it is executed out of any other directory, you'll
have to add a line like
   BEGIN { push(@INC, "/directory/SNMP_util/is/in"); }
just before the "use SNMP_util" line.  For example, where I work we'd use
   BEGIN { push(@INC, "/dept/net/mrtg/bin"); }

Check out Simon Leinen's web page, http://www.switch.ch/misc/leinen/snmp/perl
for more information about BER.pm, SNMP_session.pm, and SNMP_util.pm

-----Original Message-----
From: Andrew [mailto:awd at awd.aust.to]
Sent: Thursday, June 15, 2000 9:47 AM
To: Paul C. Williamson; mrtg at list.ee.ethz.ch
Subject: [mrtg] Re: IP Address brand router querying


----- Original Message -----
Sent: Thursday, June 15, 2000 9:54 PM
Subject: [mrtg] IP Address brand router querying


> I have an IP address list of 600 routers I monitor between two mrtg
systems.  Is there any way to use mrtg to figure out what the brand of
> each router for which I have an address is?  I know I have a mix of Bay
Networks, IBM, Cisco, 3Com, and many others.  I would like to run a script
that queries the router at ip address x and writes the brand and possibly
model into a text file.  Is there any utility out there to do this?  Help!
I don't want to have to telnet into each router just to figure out what it
is!
>
the easiest way would be to run a perl script and snmpwalk ;)

heres a quick and dirty way
--snip--
#!/usr/bin/perl -w
# get Brandnames

open ( IPLI, "/dir/to/file/of/ips");
@IPLIST = <IPLI>;
close IPLI;
$num=0;
foreach  $item(@IPLIST) {
$command = `/usr/bin/snmpwalk $item public system.sysDescr.0 `;

print "$item $command \n" ;
}
--snip--
the snmpwalk may require a -v and the paths need changing ;)
run the script with a > /file to save results to
HTH
cya
Andrew


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org



More information about the mrtg mailing list