From: Timothy Kennedy <sugarat@thunderhold.sugarat.net>
Somebody (I lost the mail) asked me for examples of my cisco homogenous
environment scripts. Here's the one to make the targets file for
cricket/config/routers/Targets.
### BOF
#!/usr/local/bin/perl -w
#
# MakeTargets: this file will get a list of targets from a flat file
# called db.router in the same directory. Easy enough to
# change, eh? --Tim
#
# Don't forget to change your paths.
#
### The hash is just the list of oid's that match the cisco routers on our
network.
### oid being the key to the router type as needed by the cricket
collector
### I am also lazy enough that this only lists the types of routers that I
### have in my network. :)
my($community) = "public";
$community = $ARGV[0] unless (! defined($ARGV[0]));
my %hash = (
"enterprises.9.1.108" => "Cisco-7200-Router",
"enterprises.9.1.14" => "Cisco-4500-Router",
"enterprises.9.1.17" => "Cisco-2500-Router",
"enterprises.9.1.19" => "Cisco-2500-Router",
"enterprises.9.1.25" => "Cisco-2500-Router",
"enterprises.9.1.30" => "Cisco-2500-Router",
"enterprises.9.1.45" => "Cisco-7500-Router",
"enterprises.9.1.46" => "Cisco-7500-Router",
"enterprises.9.1.48" => "Cisco-7500-Router",
"enterprises.9.1.50" => "Cisco-4700-Router",
);
### db.router is a list of routers, one fully qualified hostname per line.
### we generate this file on a daily basis as we add hosts from dns.
open(RTR, "db.router") ||
die "Sorry, I couldn't read db.router.";
while(<RTR>) {
chomp;
my $router = ($_);
open (GET, "snmpget -v 1 $router $community system.sysObjectId.0
|");
while($line = <GET>) {
chomp $line;
if ($line =~ /system.sysObjectId.0/i) {
my @target = split(/\s+/, $line);
if($#target == 3) {
$objid = $target[3];
}
else {
print "Can't run snmpget, or output isn't
right!\n";
}
} else {
}
}
print("target\t$router\n\tdomain\t\t=\trcn.net\n\ttarget-type\t=\t$hash{$objid}\n\tshort-desc\t=\t\"$router\"\n\n\n\n");
close GET;
}
close RTR;
### EOF
Tim Kennedy
sugarat@thunderhold.sugarat.net
Disclaimer: since this came from this me, not that ---> me,
it is persona mail, and in no way reflects any opinions or
policies of my employer, whom I won't mention here, just to
keep things clear of them. (new email policy at work)
Usual stuff about confidentiality and whatnot... intended
receivers, blah, blah, etc., etc.
------------------------------------------------------------------------
It's finally here! What's your opinion?
http://www.onelist.com
Create a Star Wars discussion group at ONElist.
This archive was generated by hypermail 2b29 : Mon Mar 06 2000 - 19:00:49 PST