many updates to BGP and interface printing

git-svn-id: http://www.observium.org/svn/observer/trunk@396 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong 2009-03-30 11:20:18 +00:00
parent f032b883d6
commit 1a514e4cd4
16 changed files with 1422 additions and 154 deletions

View File

@ -19,8 +19,8 @@ RewriteRule ^interfaces/(.+)/ ?page=interfaces&type=$1
RewriteRule ^bill/([0-9]+) ?page=bills&bill=$1
RewriteRule ^device/([0-9]+)/([a-z]+)/([a-z]+)/([a-z|0-9]+)/ ?page=device&id=$1&section=$2&opta=$3&optb=$4
RewriteRule ^device/([0-9]+)/([a-z]+)/([a-z|0-9]+)/ ?page=device&id=$1&section=$2&opta=$3
RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/ ?page=device&id=$1&section=$2&opta=$3&optb=$4
RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/ ?page=device&id=$1&section=$2&opta=$3
RewriteRule ^device/([0-9]+)/([a-z]+)/ ?page=device&id=$1&section=$2
RewriteRule ^device/([0-9]+) ?page=device&id=$1

21
html/css/mktree.css Normal file
View File

@ -0,0 +1,21 @@
/* Put this inside a @media qualifier so Netscape 4 ignores it */
@media screen, print {
/* Turn off list bullets */
ul.mktree li { list-style: none; }
/* Control how "spaced out" the tree is */
ul.mktree, ul.mktree ul , ul.mktree li { margin-left:10px; padding:0px; }
/* Provide space for our own "bullet" inside the LI */
ul.mktree li .bullet { padding-left: 15px; }
/* Show "bullets" in the links, depending on the class of the LI that the link's in */
ul.mktree li.liOpen .bullet { cursor: pointer; background: url(../images/minus.gif) center left no-repeat; }
ul.mktree li.liClosed .bullet { cursor: pointer; background: url(../images/plus.gif) center left no-repeat; }
ul.mktree li.liBullet .bullet { cursor: default; background: url(../images/bullet.gif) center left no-repeat; }
/* Sublists are visible or not based on class of parent LI */
ul.mktree li.liOpen ul { display: block; }
ul.mktree li.liClosed ul { display: none; }
/* Format menu items differently depending on what level of the tree they are in */
ul.mktree li { font-size: 12pt; }
ul.mktree li ul li { font-size: 10pt; }
ul.mktree li ul li ul li { font-size: 10pt; }
ul.mktree li ul li ul li ul li { font-size: 10pt; }
}

View File

@ -11,12 +11,10 @@
include("includes/authenticate.inc");
if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
if($_GET['params']) {
list($_GET['host'], $_GET['if'], $_GET['from'], $_GET['to'], $_GET['width'], $_GET['height'], $_GET['title'], $_GET['vertical'], $_GET['type'], $_GET['interfaces']) = explode("||", mcrypt_ecb(MCRYPT_DES, $key_value, $_GET['params'], MCRYPT_DECRYPT));
}
if($_GET['host']) {
$device_id = $_GET['host'];
} elseif($_GET['device']) {
@ -28,16 +26,9 @@
$device_id = getpeerhost($_GET['peer']);
}
if($_GET['legend']) {
$legend = $_GET['legend'];
}
if($_GET['inverse']) {
$inverse = $_GET['inverse'];
}
if($device_id) {
$hostname = gethostbyid($device_id);
}
if($_GET['legend']) { $legend = $_GET['legend']; }
if($_GET['inverse']) { $inverse = $_GET['inverse']; }
if($device_id) { $hostname = gethostbyid($device_id); }
$from = $_GET['from'];
$to = $_GET['to'];
@ -92,7 +83,7 @@
$graph = graph_mac_acc ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'device_bits':
$graph = graph_device_bits ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
$graph = graph_device_bits ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend);
break;
case 'bits':
$graph = graph_bits ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend);
@ -115,10 +106,14 @@
case 'unixfs':
$graph = unixfsgraph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'bgpupdates':
case 'bgp_updates':
$bgpPeerIdentifier = mysql_result(mysql_query("SELECT bgpPeerIdentifier FROM bgpPeers WHERE bgpPeer_id = '".$_GET['peer']."'"),0);
$graph = bgpupdatesgraph ($hostname . "/bgp-" . $bgpPeerIdentifier . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'cbgp_prefixes':
$bgpPeerIdentifier = mysql_result(mysql_query("SELECT bgpPeerIdentifier FROM bgpPeers WHERE bgpPeer_id = '".$_GET['peer']."'"),0);
$graph = graph_cbgp_prefixes ($hostname . "/cbgp-" . $bgpPeerIdentifier . ".".$_GET['afi'].".".$_GET['safi'].".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'calls':
$graph = callsgraphSNOM ($hostname . "/data.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
@ -225,7 +220,9 @@
$graph = apachebitsgraphUnix ($hostname . "/apache.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
}
break;
default:
echo("INCORRECT GRAPH TYPE");
exit;
}
if($graph) {
@ -233,7 +230,13 @@
echo(`cat graphs/$graphfile`);
} else {
header('Content-type: image/png');
echo(`cat images/no-graph.png`);
$string = "Graph Generation Error";
$im = imagecreate($width, $height);
$orange = imagecolorallocate($im, 255, 255, 255);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
imagepng($im);
imagedestroy($im);
}
$delete = `rm graphs/$graphfile`;

View File

@ -19,7 +19,8 @@
$ifHardType = $interface['ifHardType'];
if($ifAlias) {$ifAlias = $ifAlias . "</br>";}
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
#if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
if($bg == "#e5e5e5") { $bg = "#ffffff"; } else { $bg="#e5e5e5"; }
if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
$error_img = generateiflink($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);

View File

@ -68,15 +68,16 @@ if($config['enable_bgp'] && $device['bgpLocalAs']) {
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
echo("
<li class=" . $select['ifs'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ifs/'>
<img src='images/16/server_link.png' align=absmiddle border=0> Ports
</a>
</li>
<li class=" . $select['ifgraphs'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ifgraphs/'>
<img src='images/16/port_graphs.png' align=absmiddle border=0> Port Graphs
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/'>
<img src='images/16/connect.png' align=absmiddle border=0> Ports
</a>
</li>");
#<li class=" . $select['ifgraphs'] . ">
# <a href='".$config['base_url']."/device/" . $device['device_id'] . "/ifgraphs/'>
# <img src='images/16/port_graphs.png' align=absmiddle border=0> Port Graphs
# </a>
#</li>");
}
if($_SESSION[userlevel] >= "5") {

View File

@ -9,7 +9,7 @@ echo("
<a href='".$config['base_url']."/device/" . $_GET['id'] . "/bgp/bgp_updates/'>Updates</a> | Prefixes:
<a href='".$config['base_url']."/device/" . $_GET['id'] . "/bgp/cbgp_prefixes/ipv4.unicast/'>IPv4</a> |
<a href='".$config['base_url']."/device/" . $_GET['id'] . "/bgp/cbgp_prefixes/ipv4.vpn/'>VPNv4</a> |
<a href='".$config['base_url']."/device/" . $_GET['id'] . "/bgp/cbgp_updates/ipv6.unicast/'>IPv6</a>
<a href='".$config['base_url']."/device/" . $_GET['id'] . "/bgp/cbgp_prefixes/ipv6.unicast/'>IPv6</a>
</div>
</div>");
@ -34,11 +34,11 @@ echo("
$af_query = mysql_query("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '".$peer['bgpPeerIdentifier']."'");
unset($peer_af);
while($afisafi = mysql_fetch_array($af_query)) {
$afi = $afisafi['afi'];
$afi = $afisafi['afi'];
$safi = $afisafi['safi'];
$peer_af .= $sep . $config['afi'][$afi][$safi];
$peer_af .= $sep . $config['afi'][$afi][$safi]; ##### CLEAN ME UP, I AM MESSY AND I SMELL OF CHEESE!
$sep = "<br />";
$valid_afi_safi[$afi][$safi] = 1;
$valid_afi_safi[$afi][$safi] = 1; ## Build a list of valid AFI/SAFI for this peer
}
unset($sep);
echo("<tr bgcolor=$bg_colour>
@ -55,11 +55,8 @@ echo("
if($_GET['opta']) {
foreach(explode(" ", $_GET['opta']) as $graph_type) {
if($graph_type == "cbgp_prefixes") { list($afi, $safi) = explode(".", $_GET['optb']); $afisafi = "&afi=$afi&safi=$safi"; }
if($graph_type == "bgp_updates" || $valid_afi_safi[$afi][$safi]) {
$daily_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100$afisafi";
$daily_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150$afisafi";
$weekly_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100$afisafi";
@ -68,7 +65,6 @@ echo("
$monthly_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150$afisafi";
$yearly_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=210&height=100$afisafi";
$yearly_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150$afisafi";
echo("<tr bgcolor=$bg_colour><td colspan=7>");
echo("<a href='' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"><img src='$daily_traffic' border=0></a> ");
echo("<a href='' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"><img src='$weekly_traffic' border=0></a> ");

View File

@ -1,13 +0,0 @@
<?php
$hostname = gethostbyid($device['device_id']);
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
$interface_query = mysql_query("select * from interfaces WHERE device_id = '$_GET[id]' AND deleted = '0' ORDER BY `ifDescr` ASC");
while($interface = mysql_fetch_array($interface_query)) {
include("includes/print-interface.inc");
}
echo("</table></div>");
?>

View File

@ -1,16 +1,13 @@
<?php
echo("
<div style='float: right; text-align: right;'>
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/'>Details</a> | Graphs:
<div style='float: right; text-align: right; padding-bottom: 10px'>
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/'>Details</a> | Graphs:
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/bits/'>Bits</a> |
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/pkts/'>Packets</a> |
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/nupkts/'>NU Packets</a> |
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/errors/'>Errors</a>
</div>");
$dographs = 1;
if($_GET['opta'] == graphs ) {
if($_GET['optb']) {
$graph_type = $_GET['optb'];

View File

@ -10,7 +10,7 @@
if($bgpLocalAs) {
echo("AS$bgpLocalAs ");
echo("AS$bgpLocalAs \n");
if($bgpLocalAs != $device['bgpLocalAs']) { mysql_query("UPDATE devices SET bgpLocalAs = '$bgpLocalAs' WHERE device_id = '".$device['device_id']."'"); echo("Updated AS\n"); }
@ -26,15 +26,43 @@
$astext = trim(str_replace("\"", "", shell_exec("/usr/bin/dig +short AS$peer_as.asn.cymru.com TXT | cut -d '|' -f 5 | sed s/\\\"//g")));
#echo(str_pad($peer_ip, 32). str_pad($astext, 32) . " $peer_as ");
echo(str_pad($peer_ip, 40) . " AS$peer_as ");
#echo("$peer_ip AS$peer_as ");
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bgpPeers` WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'"),0) < '1') {
$add = mysql_query("INSERT INTO bgpPeers (`device_id`, `bgpPeerIdentifier`, `bgpPeerRemoteAS`) VALUES ('".$device['device_id']."','$peer_ip','$peer_as')");
echo("+");
} else {
echo(".");
$update = mysql_query("UPDATE `bgpPeers` SET astext = '$astext' WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'");
}
## Get afi/safi and populate cbgp on cisco IOS
if($device['os'] == "IOS") {
unset($af_list);
$af_cmd = $config['snmpwalk'] . " -CI -m CISCO-BGP4-MIB -OsQ -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
$af_cmd .= "cbgpPeerAddrFamilyName." . $peer_ip;
$afs = trim(str_replace("cbgpPeerAddrFamilyName.".$peer_ip.".", "", `$af_cmd`));
foreach (explode("\n", $afs) as $af) {
list($afisafi, $text) = explode(" = ", $af);
list($afi, $safi) = explode(".", $afisafi);
if($afi && $safi) {
echo("($afi:$safi)");
$af_list['$afi']['$safi'] = 1;
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bgpPeers_cbgp` WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip' AND afi = '$afi' AND safi = '$safi'"),0) == 0) {
mysql_query("INSERT INTO `bgpPeers_cbgp` (device_id,bgpPeerIdentifier, afi, safi) VALUES ('".$device['device_id']."','$peer_ip','$afi','$safi')");
}
}
}
$af_query = mysql_query("SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'");
while ($entry = mysql_fetch_array($af_query)) {
$afi = $entry['afi'];
$afi = $entry['safi'];
if (!$af_list['$afi']['$safi']) {
mysql_query("DELETE FROM `bgpPeers_cbgp` WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip' AND afi = '$afi' AND safi = '$safi'");
}
} # AF list
} # if IOS
echo("\n");
} # If Peer
} # Foreach
} else { echo("No BGP on host"); } # End if

View File

@ -7,6 +7,7 @@ $ipv6interfaces = shell_exec($config['snmpget']." -Ovnq -".$device['snmpver']."
if($ipv6interfaces){
$oids = trim(trim(shell_exec($config['snmpwalk']." -".$device['snmpver']." -Ln -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAddressIfIndex.ipv6 -Osq | grep -v No")));
echo($config['snmpwalk']." -".$device['snmpver']." -Ln -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAddressIfIndex.ipv6 -Osq | grep -v No");
$oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids); $oids = str_replace("\"", "", $oids); $oids = trim($oids);
foreach(explode("\n", $oids) as $data) {
if($data) {
@ -37,7 +38,7 @@ if($ipv6interfaces){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6addr` WHERE `addr` = '$address' AND `cidr` = '$cidr' AND `interface_id` = '$interface_id'"), 0) == '0') {
mysql_query("INSERT INTO `ip6addr` (`addr`, `comp_addr`, `cidr`, `origin`, `network`, `interface_id`) VALUES ('$address', '$comp', '$cidr', '$origin', '$network', '$interface_id')");
echo("+");
}
} else { echo("."); }
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6networks` WHERE `cidr` = '$network'"), 0) < '1') {
mysql_query("INSERT INTO `ip6networks` (`id`, `cidr`) VALUES ('', '$network')");
echo("N");
@ -47,7 +48,7 @@ if($ipv6interfaces){
mysql_query("INSERT INTO `ip6adjacencies` (`network_id`, `interface_id`) VALUES ('$network_id', '$interface_id')");
echo("A");
}
} else { echo("."); }
}
}
}
} else { echo("None configured"); }

View File

@ -7,7 +7,7 @@ include("graphing/unix.php");
function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '0') {
global $config, $installdir;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height";
if($height < "33") { $options .= " --only-graph"; }
$i = 1;
@ -65,7 +65,7 @@ function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertic
$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal ";
}
$hostname = gethostbyid($device);
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$iter = "1";
$sql = mysql_query("SELECT * FROM temperature where temp_id = '$temp'");
$opts[] = "COMMENT: Cur Max";
@ -100,7 +100,7 @@ function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $
$options .= " -l 0 -E -b 1024 --title '$title' ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$hostname = gethostbyid($device);
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$iter = "1";
$sql = mysql_query("SELECT * FROM temperature where temp_host = '$device'");
$options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n";
@ -124,55 +124,27 @@ function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $
}
function graph_device_bits ($device, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '1') {
global $config, $installdir;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height ";
if($height < "33") { $options .= " --only-graph"; }
global $config;
$hostname = gethostbyid($device);
$query = mysql_query("SELECT `ifIndex` FROM `interfaces` WHERE `device_id` = '$device' AND `ifType` NOT LIKE '%oopback%' AND `ifType` NOT LIKE '%SVI%' AND `ifType` != 'l2vlan'");
$query = mysql_query("SELECT `ifIndex`,`interface_id` FROM `interfaces` WHERE `device_id` = '$device' AND `ifType` NOT LIKE '%oopback%' AND `ifType` NOT LIKE '%SVI%' AND `ifType` != 'l2vlan'");
if($width <= "300") { $options .= "--font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$pluses = "";
while($int = mysql_fetch_row($query)) {
if(is_file($config['rrd_dir'] . "/" . $hostname . "/" . $int[0] . ".rrd")) {
$in_thing .= $seperator . "inoctets" . $int[0] . ",UN,0," . "inoctets" . $int[0] . ",IF";
$out_thing .= $seperator . "outoctets" . $int[0] . ",UN,0," . "outoctets" . $int[0] . ",IF";
$pluses .= $plus;
$seperator = ",";
$plus = ",+";
$options .= "DEF:inoctets" . $int[0] . "=" . $config['rrd_dir'] . "/" . $hostname . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE ";
$options .= "DEF:outoctets" . $int[0] . "=" . $config['rrd_dir'] . "/" . $hostname . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE ";
$interfaces .= $seperator . $int[1];
$seperator = ",";
}
}
$options .= " CDEF:inoctets=$in_thing$pluses ";
$options .= " CDEF:outoctets=$out_thing$pluses ";
$options .= " CDEF:doutoctets=outoctets,-1,* ";
$options .= " CDEF:inbits=inoctets,8,* ";
$options .= " CDEF:outbits=outoctets,8,* ";
$options .= " CDEF:doutbits=doutoctets,8,* ";
$options .= " AREA:inbits#CDEB8B: ";
$options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\\\\n ";
$options .= " LINE1.25:inbits#006600:In\ ";
$options .= " GPRINT:inbits:LAST:%6.2lf%s ";
$options .= " GPRINT:inbits:AVERAGE:%6.2lf%s ";
$options .= " GPRINT:inbits:MAX:%6.2lf%s\\\l ";
$options .= " AREA:doutbits#C3D9FF: ";
$options .= " LINE1.25:doutbits#000099:Out ";
$options .= " GPRINT:outbits:LAST:%6.2lf%s ";
$options .= " GPRINT:outbits:AVERAGE:%6.2lf%s ";
$options .= " GPRINT:outbits:MAX:%6.2lf%s ";
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
$imgfile = graph_multi_bits($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend);
return $imgfile;
}
function graph_mac_acc ($id, $graph, $from, $to, $width, $height) {
global $config;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".$id."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id");
$acc = mysql_fetch_array($query);
$database = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['peer_ip'] . ".rrd";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height ";
if($height < "33") { $options .= " --only-graph"; }
$period = $to - $from;
@ -210,17 +182,13 @@ function graph_mac_acc ($id, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l";
$options .= " LINE1:95thin#aa0000";
$options .= " LINE1:d95thout#aa0000";
#echo($config['rrdtool'] . " graph $imgfile $options");
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function graph_mac_acc_interface ($interface, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height ";
if($height < "33") { $options .= " --only-graph"; }
$hostname = gethostbyid($device);
@ -258,14 +226,13 @@ function graph_mac_acc_interface ($interface, $graph, $from, $to, $width, $heigh
return $imgfile;
}
function graph_bits ($rrd, $graph, $from, $to, $width, $height, $title, $vertical, $inverse = '0', $legend = '1') {
global $config, $installdir;
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($height < "33") { $options .= " --only-graph"; }
if($height < "33") { $options .= " --only-graph"; unset ($legend); }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
if($inverse) {
$options .= " DEF:inoctets=$database:OUTOCTETS:AVERAGE";
@ -285,32 +252,32 @@ function graph_bits ($rrd, $graph, $from, $to, $width, $height, $title, $vertica
$options .= " VDEF:95thin=inbits,95,PERCENT";
$options .= " VDEF:95thout=outbits,95,PERCENT";
$options .= " VDEF:d95thout=doutbits,5,PERCENT";
if ($legend) {
$options .= " AREA:inbits#CDEB8B:";
$options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\ \ \ 95th\ %\\\\n";
$options .= " LINE1.25:inbits#006600:In\ ";
$options .= " GPRINT:inbits:LAST:%6.2lf%s";
$options .= " GPRINT:inbits:AVERAGE:%6.2lf%s";
$options .= " GPRINT:inbits:MAX:%6.2lf%s";
$options .= " GPRINT:95thin:%6.2lf%s\\\\n";
$options .= " AREA:doutbits#C3D9FF:";
$options .= " LINE1.25:doutbits#000099:Out";
$options .= " GPRINT:outbits:LAST:%6.2lf%s";
$options .= " GPRINT:outbits:AVERAGE:%6.2lf%s";
$options .= " GPRINT:outbits:MAX:%6.2lf%s";
$options .= " GPRINT:95thout:%6.2lf%s\\\\n";
$options .= " GPRINT:tot:Total\ %6.2lf%s";
$options .= " GPRINT:totin:\(In\ %6.2lf%s";
$options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l";
$options .= " LINE1:95thin#aa0000";
$options .= " LINE1:d95thout#aa0000";
if ($legend == "no") {
$options .= " AREA:inbits#CDEB8B";
$options .= " LINE1.25:inbits#006600";
$options .= " AREA:doutbits#C3D9FF";
$options .= " LINE1.25:doutbits#000099";
$options .= " LINE1:95thin#aa0000";
$options .= " LINE1:d95thout#aa0000";
} else {
$options .= " AREA:inbits#CDEB8B";
$options .= " LINE1.25:inbits#006600";
$options .= " AREA:doutbits#C3D9FF";
$options .= " LINE1.25:doutbits#000099";
$options .= " LINE1:95thin#aa0000";
$options .= " LINE1:d95thout#aa0000";
$options .= " AREA:inbits#CDEB8B:";
$options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\ \ \ 95th\ %\\\\n";
$options .= " LINE1.25:inbits#006600:In\ ";
$options .= " GPRINT:inbits:LAST:%6.2lf%s";
$options .= " GPRINT:inbits:AVERAGE:%6.2lf%s";
$options .= " GPRINT:inbits:MAX:%6.2lf%s";
$options .= " GPRINT:95thin:%6.2lf%s\\\\n";
$options .= " AREA:doutbits#C3D9FF:";
$options .= " LINE1.25:doutbits#000099:Out";
$options .= " GPRINT:outbits:LAST:%6.2lf%s";
$options .= " GPRINT:outbits:AVERAGE:%6.2lf%s";
$options .= " GPRINT:outbits:MAX:%6.2lf%s";
$options .= " GPRINT:95thout:%6.2lf%s\\\\n";
$options .= " GPRINT:tot:Total\ %6.2lf%s";
$options .= " GPRINT:totin:\(In\ %6.2lf%s";
$options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l";
$options .= " LINE1:95thin#aa0000";
$options .= " LINE1:d95thout#aa0000";
}
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
@ -319,7 +286,7 @@ function graph_bits ($rrd, $graph, $from, $to, $width, $height, $title, $vertica
function pktsgraph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:in=$database:INUCASTPKTS:AVERAGE";
@ -343,7 +310,7 @@ function pktsgraph ($rrd, $graph, $from, $to, $width, $height) {
function errorgraph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:in=$database:INERRORS:AVERAGE";
@ -367,7 +334,7 @@ function errorgraph ($rrd, $graph, $from, $to, $width, $height) {
function nucastgraph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:in=$database:INNUCASTPKTS:AVERAGE";
@ -388,10 +355,39 @@ function nucastgraph ($rrd, $graph, $from, $to, $width, $height) {
return $imgfile;
}
function graph_cbgp_prefixes ($rrd, $graph, $from, $to, $width, $height) {
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:Accepted=$database:AcceptedPrefixes:AVERAGE";
$options .= " DEF:Denied=$database:DeniedPrefixes:AVERAGE";
$options .= " DEF:Advertised=$database:AdvertisedPrefixes:AVERAGE";
$options .= " DEF:Suppressed=$database:SuppressedPrefixes:AVERAGE";
$options .= " DEF:Withdrawn=$database:WithdrawnPrefixes:AVERAGE";
$options .= " CDEF:dAdvertised=Advertised,-1,*";
$options .= " COMMENT:Prefixes\ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\\\\n";
$options .= " AREA:Accepted#eeaaaa:";
$options .= " LINE2:Accepted#cc0000:Accepted\ \ ";
$options .= " GPRINT:Accepted:LAST:%6.2lf%s";
$options .= " GPRINT:Accepted:MIN:%6.2lf%s";
$options .= " GPRINT:Accepted:MAX:%6.2lf%s\\\\l";
$options .= " AREA:dAdvertised#aaeeaa:";
$options .= " LINE2:dAdvertised#00cc00:Advertised";
$options .= " GPRINT:Advertised:LAST:%6.2lf%s";
$options .= " GPRINT:Advertised:MIN:%6.2lf%s";
$options .= " GPRINT:Advertised:MAX:%6.2lf%s\\\\l";
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
# echo($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:in=$database:bgpPeerInUpdates:AVERAGE";
@ -415,7 +411,7 @@ function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) {
function graph_cpu_generic_single ($rrd, $graph , $from, $to, $width, $height) {
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:cpu=$database:cpu:AVERAGE";
@ -431,7 +427,7 @@ function graph_cpu_generic_single ($rrd, $graph , $from, $to, $width, $height) {
function graph_adsl_rate ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:adslAtucCurrAtt=$database:adslAtucCurrAtt:AVERAGE";
@ -452,7 +448,7 @@ function graph_adsl_rate ($rrd, $graph, $from, $to, $width, $height) {
function graph_adsl_snr ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:adslAtucCurrSnr=$database:adslAtucCurrSnr:AVERAGE";
@ -473,7 +469,7 @@ function graph_adsl_snr ($rrd, $graph, $from, $to, $width, $height) {
function graph_adsl_atn ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:adslAtucCurrAtn=$database:adslAtucCurrAtn:AVERAGE";
@ -494,7 +490,7 @@ function graph_adsl_atn ($rrd, $graph, $from, $to, $width, $height) {
function cpugraph ($rrd, $graph , $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:5s=$database:LOAD5S:AVERAGE";
@ -510,7 +506,7 @@ function cpugraph ($rrd, $graph , $from, $to, $width, $height) {
function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:uptime=$database:uptime:AVERAGE";
@ -528,7 +524,7 @@ function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $verti
function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$period = $to - $from;
$options = "-l 0 --alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
@ -559,7 +555,7 @@ function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical
function ip_graph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
@ -606,7 +602,7 @@ function ip_graph ($rrd, $graph, $from, $to, $width, $height) {
function icmp_graph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE";
@ -657,7 +653,7 @@ function icmp_graph ($rrd, $graph, $from, $to, $width, $height) {
function tcp_graph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE";
@ -704,7 +700,7 @@ function tcp_graph ($rrd, $graph, $from, $to, $width, $height) {
function udp_graph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE";

View File

@ -10,18 +10,16 @@ while($peer = mysql_fetch_array($peers)) {
### Poll BGP Peer
echo("Checking ".$peer['bgpPeerIdentifier']."\n");
echo("Checking ".$peer['bgpPeerIdentifier']." ");
$peer_cmd = $config['snmpget'] . " -m BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
$peer_cmd .= "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " ";
$peer_cmd .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " ";
$peer_cmd .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . "";
$peer_data = trim(`$peer_cmd`);
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/bgp-" . $peer['bgpPeerIdentifier'] . ".rrd";
if(!is_file($peerrrd)) {
$woo = shell_exec($config['rrdtool'] . " create $peerrrd \
DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \
@ -34,15 +32,68 @@ while($peer = mysql_fetch_array($peers)) {
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797");
}
rrdtool_update("$peerrrd", "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime");
$update = "UPDATE bgpPeers SET bgpPeerState = '$bgpPeerState', bgpPeerAdminStatus = '$bgpPeerAdminStatus', ";
$update .= "bgpPeerFsmEstablishedTime = '$bgpPeerFsmEstablishedTime', bgpPeerInUpdates = '$bgpPeerInUpdates' , bgpLocalAddr = '$bgpLocalAddr' , bgpPeerOutUpdates = '$bgpPeerOutUpdates'";
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'";
mysql_query($update);
if($device['os'] == "IOS") {
## Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB)
$afi_query = mysql_query("SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'");
while($peer_afi = mysql_fetch_array($afi_query)) {
$afi = $peer_afi['afi'];
$safi = $peer_afi['safi'];
echo($config['afi'][$afi][$safi]. " ");
$cbgp_cmd = $config['snmpget'] . " -m CISCO-BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
$cbgp_cmd .= " cbgpPeerAcceptedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
$cbgp_cmd .= " cbgpPeerDeniedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
$cbgp_cmd .= " cbgpPeerPrefixAdminLimit." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
$cbgp_cmd .= " cbgpPeerPrefixThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
$cbgp_cmd .= " cbgpPeerPrefixClearThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
$cbgp_cmd .= " cbgpPeerAdvertisedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
$cbgp_cmd .= " cbgpPeerSuppressedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
$cbgp_cmd .= " cbgpPeerWithdrawnPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
echo("\n$cbgp_cmd\n");
$cbgp_data = preg_replace("/^OID.*$/", "", trim(`$cbgp_cmd`));
list($cbgpPeerAcceptedPrefixes,$cbgpPeerDeniedPrefixes,$cbgpPeerPrefixAdminLimit,$cbgpPeerPrefixThreshold,$cbgpPeerPrefixClearThreshold,$cbgpPeerAdvertisedPrefixes,$cbgpPeerSuppressedPrefixes,$cbgpPeerWithdrawnPrefixes) = explode("\n", $cbgp_data);
$update = "UPDATE bgpPeers_cbgp SET";
$update .= " `cbgpPeerAcceptedPrefixes` = '$cbgpPeerAcceptedPrefixes'";
$update .= ", `cbgpPeerDeniedPrefixes` = '$cbgpPeerDeniedPrefixes'";
$update .= ", `cbgpPeerPrefixAdminLimit` = '$cbgpPeerAdminLimit'";
$update .= ", `cbgpPeerPrefixThreshold` = '$cbgpPeerPrefixThreshold'";
$update .= ", `cbgpPeerPrefixClearThreshold` = '$cbgpPeerPrefixClearThreshold'";
$update .= ", `cbgpPeerAdvertisedPrefixes` = '$cbgpPeerAdvertisedPrefixes'";
$update .= ", `cbgpPeerSuppressedPrefixes` = '$cbgpPeerSuppressedPrefixes'";
$update .= ", `cbgpPeerWithdrawnPrefixes` = '$cbgpPeerWithdrawnPrefixes'";
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "' AND afi = '$afi' AND safi = '$safi'";
mysql_query($update);
$cbgp_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/cbgp-" . $peer['bgpPeerIdentifier'] . ".$afi.$safi.rrd";
if(!is_file($cbgp_rrd)) {
$woo = shell_exec($config['rrdtool'] . " create $cbgp_rrd \
DS:AcceptedPrefixes:GAUGE:600:U:100000000000 \
DS:DeniedPrefixes:GAUGE:600:U:100000000000 \
DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 \
DS:SuppressedPrefixes:GAUGE:600:U:100000000000 \
DS:WithdrawnPrefixes:GAUGE:600:U:100000000000 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797");
}
rrdtool_update("$cbgp_rrd", "N:$cbgpPeerAcceptedPrefixes:$cbgpPeerDeniedPrefixes:$cbgpPeerAdvertisedPrefixes:$cbgpPeerSuppressedPrefixes:$cbgpPeerWithdrawnPrefixes");
}
}
echo("\n");
} ## End While loop on peers
} ## End check for BGP support

View File

@ -5,6 +5,14 @@ $config['ifdescr']['IOS'] = true;
$config['ifdescr']['IOS XE'] = true;
## AFI / SAFI pairs for BGP (and other stuff, perhaps)
$config['afi']['ipv4']['unicast'] = "IPv4";
$config['afi']['ipv4']['multiicast'] = "IPv4 Multicast";
$config['afi']['ipv4']['vpn'] = "VPNv4";
$config['afi']['ipv6']['unicast'] = "IPv6";
$config['afi']['ipv6']['multicast'] = "IPv6 Multicast";
##############################
# No changes below this line #
##############################

1169
mibs/CISCO-BGP4-MIB.my Normal file

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,7 @@ while ($device = mysql_fetch_array($device_query)) {
echo("Polling " . $device['hostname'] . " ( device_id ".$device['device_id']." )\n\n");
unset($update); unset($update_query); unset($seperator); unset($version); unset($uptime); unset($features);
unset($sysLocation); unset($hardware); unset($sysDescr); unset($sysContact);
unset($sysLocation); unset($hardware); unset($sysDescr); unset($sysContact); unset($sysName);
$pingable = isPingable($device['hostname']);

View File

@ -28,6 +28,14 @@ if($argv[1] == "--device" && $argv[2]) {
exit;
}
if ($argv[2] == "--type" && $argv[3]) {
$type = $argv[3];
} elseif ($argv[3] == "--type" && $argv[4]) {
$type = $argv[4];
} else {
echo("Require valid discovery type.\n");
exit;
}
$devices_polled = 0;
@ -36,12 +44,13 @@ while ($device = mysql_fetch_array($device_query)) {
echo($device['hostname'] ."\n");
# include("includes/discovery/cisco-physical.php");
# include("includes/discovery/ipv6-addresses.php");
# include("includes/discovery/cisco-pw.php");
include("includes/discovery/".$type.".php");
# include("includes/discovery/ipv6-addresses.php");
# include("includes/discovery/cisco-pw.php");
include("includes/discovery/host-physical.php");
# include("includes/discovery/host-physical.php");
# include("includes/discovery/bgp-peers.php");
echo("\n"); $devices_polled++;
}