Révision fc7eca20
bugfix
| plugins/other/cisco_bgp_ | ||
|---|---|---|
| 4 | 4 |
# |
| 5 | 5 |
# Original Author: Peter Holzleitner |
| 6 | 6 |
# |
| 7 |
# Revision 1.0 2009/05/04 16:00:00 holzlp |
|
| 8 |
# Initial version |
|
| 7 |
# Revision 1.1 2010/10/14 19:19 |
|
| 9 | 8 |
# |
| 10 | 9 |
# Configuration variables: |
| 11 | 10 |
# |
| ... | ... | |
| 22 | 21 |
|
| 23 | 22 |
|
| 24 | 23 |
use Net::Telnet::Cisco; |
| 24 |
use Sys::Syslog; |
|
| 25 | 25 |
|
| 26 | 26 |
|
| 27 | 27 |
if ($0 =~ /^(?:|.*\/)cisco_bgp_([^_]+)$/) {
|
| 28 | 28 |
$host = $1; |
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
|
|
| 32 |
|
|
| 33 |
if ($ARGV[0] and $ARGV[0] eq "autoconf") |
|
| 34 |
{
|
|
| 35 |
if (-r "/proc/meminfo") |
|
| 36 |
{
|
|
| 37 |
print "yes\n"; |
|
| 38 |
exit 0; |
|
| 39 |
} |
|
| 40 |
else |
|
| 41 |
{
|
|
| 42 |
print "/proc/meminfo not found\n"; |
|
| 43 |
exit 1; |
|
| 44 |
} |
|
| 45 |
} |
|
| 31 |
($^O eq "linux" || $^O eq "openbsd") && Sys::Syslog::setlogsock('unix');
|
|
| 32 |
openlog('munin.bgp', 'cons,pid', 'daemon');
|
|
| 46 | 33 |
|
| 47 | 34 |
|
| 48 | 35 |
my @BGP_nbr; |
| ... | ... | |
| 89 | 76 |
my $username = shift; |
| 90 | 77 |
my $password = shift; |
| 91 | 78 |
my $session = Net::Telnet::Cisco->new(Host => $host); |
| 79 |
|
|
| 92 | 80 |
$session->login($username, $password); |
| 81 |
$session->cmd('terminal length 200');
|
|
| 82 |
$session->cmd('terminal width 200');
|
|
| 93 | 83 |
my @output = $session->cmd('show ip bgp summary');
|
| 94 | 84 |
|
| 95 |
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd |
|
| 96 |
# 12.23.34.45 4 9999 410819 9522 2401634 0 0 6d14h 281237 |
|
| 85 |
# example output of router |
|
| 86 |
# ------------------------ |
|
| 87 |
# [...] |
|
| 88 |
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd |
|
| 89 |
# 11.111.11.111 4 98765 12403694 509571 308911893 0 0 1d23h 329193 |
|
| 90 |
# 122.122.122.122 4 1234 13242856 383827 308911879 0 0 00:08:22 330761 |
|
| 97 | 91 |
|
| 98 | 92 |
foreach(@output) {
|
| 93 |
chomp; s/\r//g; |
|
| 99 | 94 |
$tot_pfx = $1 if /^BGP activity (\d+)\/(\d+) prefixes/; |
| 100 |
next unless /^(\d+\.\d+\.\d+\.\d+)\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+[0-9a-z]+\s+(\d+)/; |
|
| 95 |
syslog('debug', "$hostname: $_\n");
|
|
| 96 |
|
|
| 97 |
next unless /^(\d+\.\d+\.\d+\.\d+)\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+[0-9a-z:]+\s+(\d+)/; |
|
| 101 | 98 |
my ($neigh, $as, $pfx) = ($1, $2, $3); |
| 99 |
syslog('debug', "$neigh (AS $as)");
|
|
| 102 | 100 |
push @BGP_nbr, "$neigh (AS $as)"; |
| 103 | 101 |
push @BGP_pfx, $pfx; |
| 104 | 102 |
} |
Formats disponibles : Unified diff