mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
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:
@@ -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
|
||||
|
||||
@@ -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"); }
|
||||
|
||||
+82
-86
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 #
|
||||
##############################
|
||||
|
||||
Reference in New Issue
Block a user