mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add BGP detection and polling. Fix a lot of other things.
git-svn-id: http://www.observium.org/svn/observer/trunk@161 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -53,16 +53,15 @@ $config['overlib_defaults'] = ",FGCOLOR,'#e5e5e5', BGCOLOR, '#e5e5e5'";
|
||||
|
||||
|
||||
### List of networks to allow scanning-based discovery
|
||||
$nets = array ("192.168.0.0/24", "10.0.0.0/8");
|
||||
$config['nets'] = array ("192.168.0.0/24", "10.0.0.0/8");
|
||||
|
||||
### Your company domain name
|
||||
$config['mydomain'] = "project-observer.org";
|
||||
$mydomain = $config['mydomain'];
|
||||
$page_title = "Observer Demo";
|
||||
$title_image = "/images/observer-header.png";
|
||||
$stylesheet = "/css/styles.css";
|
||||
$config['page_title'] = "Observer Demo";
|
||||
$config['title_image'] = "/images/observer-header.png";
|
||||
$config['stylesheet'] = "/css/styles.css";
|
||||
$mono_font = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf";
|
||||
$favicon = "/favicon.ico";
|
||||
$config['favicon'] = "/favicon.ico";
|
||||
|
||||
$config['email_default'] = "admin@project-observer.org";
|
||||
$config['email_from'] = "observer@project-observer.org";
|
||||
|
4
cron.sh
4
cron.sh
@@ -1,10 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
#./poll-reachability.php
|
||||
./discover-bgp_peers.php >> /var/log/observer.log &
|
||||
./poll-device.php --odd >> /var/log/observer.log &
|
||||
./poll-device.php --even >> /var/log/observer.log &
|
||||
#./ips.php &
|
||||
./check-services.php
|
||||
#./alerts.php
|
||||
|
||||
./poll-billing.php
|
||||
|
99
discover-bgp_peers.php
Executable file
99
discover-bgp_peers.php
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
|
||||
### Discover BGP peers on Cisco devices
|
||||
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND os = 'IOS' ORDER BY device_id desc");
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
echo("\nPolling ". $device['hostname'] . "\n");
|
||||
|
||||
$as_cmd = $config['snmpwalk'] . " -CI -Oqvn -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'] . " ";
|
||||
$as_cmd .= ".1.3.6.1.2.1.15.2";
|
||||
$bgpLocalAs = trim(`$as_cmd`);
|
||||
|
||||
if($bgpLocalAs) {
|
||||
|
||||
echo("Host AS is $bgpLocalAs\n");
|
||||
|
||||
if($bgpLocalAs != $device['bgpLocalAs']) { mysql_query("UPDATE devices SET bgpLocalAs = '$bgpLocalAs' WHERE device_id = '".$device['device_id']."'"); echo("Updated AS\n"); }
|
||||
|
||||
$peers_cmd = $config['snmpwalk'] . " -CI -Oq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'] . " ";
|
||||
$peers_cmd .= "BGP4-MIB::bgpPeerRemoteAs";
|
||||
$peers = trim(str_replace("BGP4-MIB::bgpPeerRemoteAs.", "", `$peers_cmd`));
|
||||
foreach (explode("\n", $peers) as $peer) {
|
||||
|
||||
if($peer) {
|
||||
list($peer_ip, $peer_as) = split(" ", $peer);
|
||||
|
||||
$astext = trim(`/usr/bin/dig +short AS$peer_as.asn.cymru.com TXT | sed s/\"//g | cut -d "|" -f 5`);
|
||||
|
||||
echo(str_pad($peer_ip, 32). str_pad($astext, 32) . " $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')");
|
||||
if($add) { echo(" Added \n"); } else { echo(" Add failed\n"); }
|
||||
} else { echo(" Exists\n"); }
|
||||
|
||||
### Poll BGP Peer
|
||||
|
||||
$peer_cmd = $config['snmpget'] . " -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'] . " ";
|
||||
$peer_cmd .= "bgpPeerState.$peer_ip bgpPeerAdminStatus.$peer_ip bgpPeerInUpdates.$peer_ip bgpPeerOutUpdates.$peer_ip bgpPeerInTotalMessages.$peer_ip ";
|
||||
$peer_cmd .= "bgpPeerOutTotalMessages.$peer_ip bgpPeerFsmEstablishedTime.$peer_ip bgpPeerInUpdateElapsedTime.$peer_ip";
|
||||
$peer_data = trim(`$peer_cmd`);
|
||||
|
||||
$peerrrd = $rrd_dir . "/" . $device['hostname'] . "/bgp-$peer_ip.rrd";
|
||||
|
||||
if(!is_file($peerrrd)) {
|
||||
$woo = `rrdtool create $peerrrd \
|
||||
DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerEstablished:GAUGE:600:0:U \
|
||||
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($peerrrd, "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime");
|
||||
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime) = explode("\n", $peer_data);
|
||||
|
||||
$update = "UPDATE bgpPeers SET bgpPeerState = '$bgpPeerState', bgpPeerAdminStatus = '$bgpPeerAdminStatus', ";
|
||||
$update .= "bgpPeerFsmEstablishedTime = '$bgpPeerFsmEstablishedTime', astext = '$astext'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'";
|
||||
|
||||
mysql_query($update);
|
||||
|
||||
} # end if $peer
|
||||
} # End foreach
|
||||
} # End BGP check
|
||||
} # End While
|
||||
|
||||
## Delete removed sensors
|
||||
|
||||
$sql = "SELECT * FROM temperature AS T, devices AS D WHERE T.temp_host = D.device_id AND D.status = '1'";
|
||||
$query = mysql_query($sql);
|
||||
|
||||
while ($sensor = mysql_fetch_array($query)) {
|
||||
unset($exists);
|
||||
$i = 0;
|
||||
while ($i < count($temp_exists) && !$exists) {
|
||||
$thistemp = $sensor['temp_host'] . " " . $sensor['temp_oid'];
|
||||
if ($temp_exists[$i] == $thistemp) { $exists = 1; }
|
||||
$i++;
|
||||
}
|
||||
if(!$exists) {
|
||||
# echo("Deleting...\n");
|
||||
# mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -36,11 +36,11 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
$dst_if = strtolower($dst_if);
|
||||
$src_host = strtolower($src_host);
|
||||
$src_if = strtolower($src_if);
|
||||
if ( isDomainResolves($dst_host . "." . $mydomain) ) {
|
||||
$dst_host = $dst_host . "." . $mydomain;
|
||||
if ( isDomainResolves($dst_host . "." . $config['mydomain']) ) {
|
||||
$dst_host = $dst_host . "." . $config['mydomain'];
|
||||
}
|
||||
$ip = gethostbyname($dst_host);
|
||||
if ( match_network($nets, $ip) ) {
|
||||
if ( match_network($config['nets'], $ip) ) {
|
||||
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$dst_host'"), 0) == '0' ) {
|
||||
createHost ($dst_host, $community, "v2c");
|
||||
} else {
|
||||
|
@@ -17,7 +17,7 @@ while ($data = mysql_fetch_array($query)) {
|
||||
$end = ip2long($broadcast);
|
||||
while($ip < $end) {
|
||||
$ipdotted = long2ip($ip);
|
||||
if(mysql_result(mysql_query("SELECT count(id) FROM ipaddr WHERE addr = '$ipdotted'"),0) == '0' && match_network($nets, $ipdotted)) {
|
||||
if(mysql_result(mysql_query("SELECT count(id) FROM ipaddr WHERE addr = '$ipdotted'"),0) == '0' && match_network($config['nets'], $ipdotted)) {
|
||||
fputs($handle, $ipdotted . "\n");
|
||||
}
|
||||
$ip++;
|
||||
|
@@ -22,7 +22,11 @@
|
||||
} elseif($_GET['if']) {
|
||||
$device_id = getifhost($_GET['if']);
|
||||
$ifIndex = getifindexbyid($_GET['if']);
|
||||
} elseif($_GET['peer']) {
|
||||
$device_id = getpeerhost($_GET['peer']);
|
||||
}
|
||||
|
||||
|
||||
if($device_id) {
|
||||
$hostname = gethostbyid($device_id);
|
||||
}
|
||||
@@ -71,6 +75,10 @@
|
||||
case 'unixfs':
|
||||
$graph = unixfsgraph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
break;
|
||||
case 'bgpupdates':
|
||||
$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 'calls':
|
||||
$graph = callsgraphSNOM ($hostname . "/data.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
break;
|
||||
|
@@ -28,11 +28,11 @@ if($_GET[debug]) {
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title><?php echo("$page_title"); ?></title>
|
||||
<base href="<?php echo("$base_url"); ?>" />
|
||||
<base href="<?php echo($config['base_url']); ?>" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<!-- <meta http-equiv="refresh" content="300"> -->
|
||||
<link href="<?php echo($stylesheet); ?>" rel="stylesheet" type="text/css">
|
||||
<link rel="shortcut icon" href="<?php echo($favicon); ?>" />
|
||||
<link href="<?php echo($config['stylesheet']); ?>" rel="stylesheet" type="text/css">
|
||||
<link rel="shortcut icon" href="<?php echo($config['favicon']); ?>" />
|
||||
<link rel="stylesheet" href="css/mktree.css" type="text/css">
|
||||
</head>
|
||||
<script type="text/javascript" src="js/mktree.js"></script>
|
||||
@@ -55,7 +55,7 @@ function popUp(URL) {
|
||||
<td align=right>
|
||||
<?
|
||||
if($_SESSION['authenticated']) {
|
||||
echo("Logged in as <b>$_SESSION[username]</b> (<a href='?logout=yes'>Logout</a>)");
|
||||
echo("Logged in as <b>".$_SESSION['username']."</b> (<a href='?logout=yes'>Logout</a>)");
|
||||
} else {
|
||||
echo("Not logged in!");
|
||||
}
|
||||
@@ -68,7 +68,7 @@ function popUp(URL) {
|
||||
<table width="100%" style="padding: 0px; margin:0px;">
|
||||
<tr>
|
||||
<td style="padding: 0px; margin:0px; border: none;">
|
||||
<div id=logo style="padding: 10px"><a href="index.php"><img src="<?php echo("$title_image"); ?>" border="0" /></a></div>
|
||||
<div id=logo style="padding: 10px"><a href="index.php"><img src="<?php echo($config['title_image']); ?>" border="0" /></a></div>
|
||||
</td>
|
||||
<td align=right style="margin-right: 10px;">
|
||||
<div id="topnav" style="float: right;">
|
||||
|
@@ -36,6 +36,15 @@ if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id =
|
||||
</li>");
|
||||
}
|
||||
|
||||
if($device['bgpLocalAs']) {
|
||||
echo("
|
||||
<li class=" . $select['dev-bgp'] . ">
|
||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-bgp' >
|
||||
<img src='images/16/link.png' align=absmiddle border=0> BGP
|
||||
</a>
|
||||
</li>");
|
||||
}
|
||||
|
||||
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||
echo("
|
||||
<li class=" . $select['dev-ifs'] . ">
|
||||
|
56
html/pages/device/dev-bgp.inc
Normal file
56
html/pages/device/dev-bgp.inc
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
|
||||
$i = "1";
|
||||
$peer_query = mysql_query("select * from bgpPeers WHERE device_id = '".$device['device_id']."' ORDER BY bgpPeerRemoteAs, bgpPeerIdentifier");
|
||||
while($peer = mysql_fetch_array($peer_query)) {
|
||||
|
||||
if(!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
|
||||
if($peer['bgpPeerAdminStatus'] == "start") { $img = "images/16/accept.png"; } else { $img = "images/16/delete.png"; }
|
||||
if($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $bg_colour = "#fcc"; }
|
||||
|
||||
|
||||
$peerhost = mysql_fetch_array(mysql_query("SELECT * FROM ipaddr AS A, interfaces AS I, devices AS D WHERE A.addr = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
|
||||
|
||||
if($peerhost) { $peername = generatedevicelink($peerhost); } else { unset($peername); }
|
||||
|
||||
echo("<tr bgcolor=$bg_colour><th>$i</td><td><span class=list-large>" . $peer['bgpPeerIdentifier'] . "</span><br />".$peername."</td><td>AS" . $peer['bgpPeerRemoteAs'] . "<br />" . $peer['astext'] . "</td><td><img src='$img'></td><td><span style='color: $col;'>" . $peer['bgpPeerState'] . "</span></td><td>" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "</td></tr>");
|
||||
|
||||
# if($graphs) {
|
||||
|
||||
$graph_type = "bgpupdates";
|
||||
|
||||
$daily_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100";
|
||||
$daily_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150";
|
||||
|
||||
$weekly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100";
|
||||
$weekly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150";
|
||||
|
||||
$monthly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=210&height=100";
|
||||
$monthly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150";
|
||||
|
||||
$yearly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=210&height=100";
|
||||
$yearly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150";
|
||||
|
||||
echo("<tr><td colspan=6>");
|
||||
|
||||
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
|
||||
<img src='$daily_traffic' border=0></a> ");
|
||||
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
|
||||
<img src='$weekly_traffic' border=0></a> ");
|
||||
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
|
||||
<img src='$monthly_traffic' border=0></a> ");
|
||||
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
|
||||
<img src='$yearly_traffic' border=0></a>");
|
||||
|
||||
|
||||
echo("</td></tr>");
|
||||
|
||||
|
||||
# }
|
||||
|
||||
$i++;
|
||||
}
|
||||
echo("</table></div>");
|
||||
|
||||
?>
|
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
if (isset($_GET["dir"])) {
|
||||
$dir = $_GET["dir"];
|
||||
} else {
|
||||
|
@@ -604,6 +604,12 @@ function getifhost($id) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getpeerhost($id) {
|
||||
$sql = mysql_query("SELECT `device_id` from `bgpPeers` WHERE `bgpPeer_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getifindexbyid($id) {
|
||||
$sql = mysql_query("SELECT `ifIndex` FROM `interfaces` WHERE `interface_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
|
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height";
|
||||
foreach(explode("\n", $interfaces) as $ifid) {
|
||||
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
|
||||
$int = mysql_fetch_row($query);
|
||||
if(is_file($rrd_dir . "/" . $int[1] . "/" . $int[0] . ".rrd")) {
|
||||
$options .= " DEF:inoctets" . $int[0] . "=" . $rrd_dir . "/" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE";
|
||||
$options .= " DEF:outoctets" . $int[0] . "=" . $rrd_dir . "/" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE";
|
||||
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) {
|
||||
$options .= " DEF:inoctets" . $int[0] . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE";
|
||||
$options .= " DEF:outoctets" . $int[0] . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE";
|
||||
$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;
|
||||
@@ -131,7 +131,7 @@ function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $
|
||||
}
|
||||
|
||||
function graph_device_bits ($device, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height ";
|
||||
$hostname = gethostbyid($device);
|
||||
@@ -139,14 +139,14 @@ function graph_device_bits ($device, $graph, $from, $to, $width, $height) {
|
||||
if($width <= "300") { $options .= "--font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
|
||||
$pluses = "";
|
||||
while($int = mysql_fetch_row($query)) {
|
||||
if(is_file($rrd_dir . "/" . $hostname . "/" . $int[0] . ".rrd")) {
|
||||
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] . "=" . $rrd_dir . "/" . $hostname . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE ";
|
||||
$options .= "DEF:outoctets" . $int[0] . "=" . $rrd_dir . "/" . $hostname . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE ";
|
||||
$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 ";
|
||||
}
|
||||
}
|
||||
$options .= " CDEF:inoctets=$in_thing$pluses ";
|
||||
@@ -171,8 +171,8 @@ function graph_device_bits ($device, $graph, $from, $to, $width, $height) {
|
||||
}
|
||||
|
||||
function trafgraph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$period = $to - $from;
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
@@ -213,8 +213,8 @@ function trafgraph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
}
|
||||
|
||||
function pktsgraph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
|
||||
@@ -237,8 +237,8 @@ function pktsgraph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
}
|
||||
|
||||
function errorgraph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
|
||||
@@ -261,8 +261,8 @@ function errorgraph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
}
|
||||
|
||||
function nucastgraph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
|
||||
@@ -284,9 +284,34 @@ function nucastgraph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
return $imgfile;
|
||||
}
|
||||
|
||||
function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
if($width <= "300") {$options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
|
||||
$options .= " DEF:in=$database:bgpPeerInUpdates:AVERAGE";
|
||||
$options .= " DEF:out=$database:bgpPeerOutUpdates:AVERAGE";
|
||||
$options .= " CDEF:dout=out,-1,*";
|
||||
$options .= " AREA:in#aa66aa:";
|
||||
$options .= " COMMENT:Updates\ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ \ Maximum\\\\n";
|
||||
$options .= " LINE1.25:in#330033:In\ \ ";
|
||||
$options .= " GPRINT:in:LAST:%6.2lf%sU/s";
|
||||
$options .= " GPRINT:in:AVERAGE:%6.2lf%sU/s";
|
||||
$options .= " GPRINT:in:MAX:%6.2lf%sU/s\\\\n";
|
||||
$options .= " AREA:dout#FFDD88:";
|
||||
$options .= " LINE1.25:dout#FF6600:Out\ ";
|
||||
$options .= " GPRINT:out:LAST:%6.2lf%sU/s";
|
||||
$options .= " GPRINT:out:AVERAGE:%6.2lf%sU/s";
|
||||
$options .= " GPRINT:out:MAX:%6.2lf%sU/s\\\\n";
|
||||
$thing = `$rrdtool graph $imgfile $options`;
|
||||
return $imgfile;
|
||||
}
|
||||
|
||||
|
||||
function cpugraph ($rrd, $graph , $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
if($width <= "300") {$options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
|
||||
@@ -301,8 +326,8 @@ function cpugraph ($rrd, $graph , $from, $to, $width, $height) {
|
||||
}
|
||||
|
||||
function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
|
||||
@@ -319,8 +344,8 @@ function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $verti
|
||||
|
||||
|
||||
function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$period = $to - $from;
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
@@ -350,8 +375,8 @@ function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical
|
||||
}
|
||||
|
||||
function ip_graph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$period = $to - $from;
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
@@ -397,8 +422,8 @@ function ip_graph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
}
|
||||
|
||||
function icmp_graph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$period = $to - $from;
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
@@ -448,8 +473,8 @@ function icmp_graph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
}
|
||||
|
||||
function tcp_graph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$period = $to - $from;
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
@@ -495,8 +520,8 @@ function tcp_graph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
}
|
||||
|
||||
function udp_graph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$database = $rrd_dir . "/" . $rrd;
|
||||
global $config, $rrdtool, $installdir, $mono_font;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$period = $to - $from;
|
||||
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
|
@@ -19,7 +19,7 @@ while ($device = mysql_fetch_array($q)) {
|
||||
$address = $oid;
|
||||
$cidr = netmask2cidr($netmask);
|
||||
$network = trim(`$ipcalc $address/$mask | grep Network | cut -d" " -f 4`);
|
||||
if (match_network($nets, $address) && $network != "") {
|
||||
if (match_network($config['nets'], $address) && $network != "") {
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `networks` WHERE `cidr` = '$network'"), 0) < '1') {
|
||||
$woo = mysql_query("INSERT INTO `networks` (`id`, `cidr`) VALUES ('', '$network')");
|
||||
echo("Create Subnet $network\n");
|
||||
|
2
ips.php
2
ips.php
@@ -34,7 +34,7 @@ while ($device = mysql_fetch_array($q)) {
|
||||
echo("Create Subnet $network\n");
|
||||
}
|
||||
$network_id = mysql_result(mysql_query("SELECT id from `networks` WHERE `cidr` = '$network'"), 0);
|
||||
if (match_network($nets, $address) && mysql_result(mysql_query("SELECT COUNT(*) FROM `adjacencies` WHERE `network_id` = '$network_id' AND `interface_id` = '$interface_id'"), 0) < '1') {
|
||||
if (match_network($config['nets'], $address) && mysql_result(mysql_query("SELECT COUNT(*) FROM `adjacencies` WHERE `network_id` = '$network_id' AND `interface_id` = '$interface_id'"), 0) < '1') {
|
||||
mysql_query("INSERT INTO `adjacencies` (`network_id`, `interface_id`) VALUES ('$network_id', '$interface_id')");
|
||||
echo("Create Adjacency : $hostname, $interface_id, $network_id, $network, $ifIndex\n");
|
||||
}
|
||||
|
14
map.php
14
map.php
@@ -34,15 +34,15 @@ while($loc_data = mysql_fetch_array($loc_result)) {
|
||||
while($dev_data = mysql_fetch_array($dev_result)) {
|
||||
$host = $dev_data['hostname'];
|
||||
unset($hostinfo);
|
||||
if(strpos($host, "cust." . $mydomain)) { $hostinfo = "shape=egg style=filled fillcolor=pink"; }
|
||||
elseif(strpos($host, $mydomain)) {
|
||||
if(strpos($host, "cust." . $config['mydomain'])) { $hostinfo = "shape=egg style=filled fillcolor=pink"; }
|
||||
elseif(strpos($host, $config['mydomain'])) {
|
||||
if(strpos($host, "-sw")||strpos($host, "-cs")) { $hostinfo = "shape=rectangle style=filled fillcolor=skyblue"; }
|
||||
if(strpos($host, "-gw")||strpos($host, "-pe")||strpos($host, "-er")) { $hostinfo = "shape=ellipse style=filled fillcolor=darkolivegreen3"; }
|
||||
if(strpos($host, "-lns")) { $hostinfo = "shape=egg style=filled fillcolor=darkolivegreen4"; }
|
||||
} else { $hostinfo = "style=filled shape=circle fillcolor=lightgray"; }
|
||||
|
||||
$host = $dev_data[hostname];
|
||||
$host = str_replace("." . $mydomain,"", $host);
|
||||
$host = str_replace("." . $config['mydomain'],"", $host);
|
||||
echo("\"$host\" [$hostinfo]
|
||||
");
|
||||
|
||||
@@ -64,8 +64,8 @@ while($loc_data = mysql_fetch_array($loc_result)) {
|
||||
$src_speed = $sq[1];
|
||||
$dst_speed = $dq[1];
|
||||
|
||||
$src = str_replace("." . $mydomain, "", $src);
|
||||
$dst = str_replace("." . $mydomain, "", $dst);
|
||||
$src = str_replace("." . $config['mydomain'], "", $src);
|
||||
$dst = str_replace("." . $config['mydomain'], "", $dst);
|
||||
|
||||
$info = "";
|
||||
|
||||
@@ -125,8 +125,8 @@ while($link_data = mysql_fetch_array($links_result)) {
|
||||
$src_speed = $sq[1];
|
||||
$dst_speed = $dq[1];
|
||||
|
||||
$src = str_replace("." . $mydomain, "", $src);
|
||||
$dst = str_replace("." . $mydomain, "", $dst);
|
||||
$src = str_replace("." . $config['mydomain'], "", $src);
|
||||
$dst = str_replace("." . $config['mydomain'], "", $dst);
|
||||
|
||||
$info = "";
|
||||
|
||||
|
Reference in New Issue
Block a user