[c-nsp] CoPP & Cacti Graph

hjan hjan at libero.it
Sat Nov 4 06:15:31 EST 2006


I wrote this simple perl script for monitor control-plane policy-map with 
cacti:

#!/usr/bin/perl
use Net::Telnet::Cisco;

#DATI
$rate="";
$blocco=1;
my $user = "USER";
chomp $user;
my $pass = "PWD";
chomp $pass;


#Inizio sessione telnet
my $session = Net::Telnet::Cisco->new(Host => $ARGV[0]);
$session->login($user, $pass);

# Execute a command
my @output = $session->cmd("show policy-map control-plane input class
$ARGV[1]");
foreach (@output) {
if ($_ =~ m/\d+ bps/) {
#$rate= $&;
@_=split(/bps/,$&);
$rate= $_[0];
}
if ($rate gt "" && $blocco == 1){
print $rate;
$blocco+=1;}
}
$session->close;

it runs with script-name.pl rtr-ip-address class-to-monitor.

Hope this can help someother, i've not found a better way to do this.

Regards,
Gianluca




More information about the cisco-nsp mailing list