allow customisable filtering of interfaces from device_bits graph (also usable on theoretical device_pkts and device_errors)

git-svn-id: http://www.observium.org/svn/observer/trunk@1068 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-04-20 15:46:17 +00:00
parent caa5d5e4a0
commit 38a33e5661
8 changed files with 188 additions and 81 deletions
+26 -6
View File
@@ -2,14 +2,34 @@
## Generate a list of ports and then call the multi_bits grapher to generate from the list
$device = mres($_GET['device']);
$hostname = gethostbyid($device);
if($_GET['device']) {
$device = device_by_id_cache(mres($_GET['device']));
} elseif($_GET['id']) {
$device = device_by_id_cache(mres($_GET['id']));
}
$query = mysql_query("SELECT `ifIndex`,`interface_id` FROM `ports` WHERE `device_id` = '$device' AND `ifType` NOT LIKE '%oopback%' AND `ifType` NOT LIKE '%SVI%' AND `ifType` != 'l2vlan'");
while($int = mysql_fetch_row($query)) {
if(is_file($config['rrd_dir'] . "/" . $hostname . "/" . safename($int[0] . ".rrd"))) {
$rrd_filenames[] = $config['rrd_dir'] . "/" . $hostname . "/" . safename($int[0] . ".rrd");
$query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."'");
while($int = mysql_fetch_assoc($query)) {
$ignore = 0;
if(is_array($config['device_traffic_iftype'])) {
foreach($config['device_traffic_iftype'] as $iftype) {
if (preg_match($iftype ."i", $int['ifType'])) {
$ignore = 1;
}
}
}
if(is_array($config['device_traffic_descr'])) {
foreach($config['device_traffic_descr'] as $ifdescr) {
if (preg_match($ifdescr."i", $int['ifDescr']) || preg_match($ifdescr."i", $int['ifName']) || preg_match($ifdescr."i", $int['portName'])) {
$ignore = 1;
}
}
}
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($int['ifIndex'] . ".rrd")) && $ignore != 1) {
$rrd_filenames[] = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($int['ifIndex'] . ".rrd");
}
unset($ignore);
}
$rra_in = "INOCTETS";
+2 -2
View File
@@ -162,8 +162,8 @@ echo('<li><a href="ports/?status=0"><img src="images/16/link_error.png" border="
<!--[if IE 7]><!--></a><!--<![endif]-->
<table><tr><td>
<ul>
<li><a href="health/processors/"><img src="images/icons/cpuload.png" border="0" align="absmiddle" /> Processorss</a></li>
<li><a href="health/memory/"><img src="images/icons/mempool.png" border="0" align="absmiddle" /> Memory</a></li>
<li><a href="health/processors/"><img src="images/icons/overview/processors.png" border="0" align="absmiddle" /> Processorss</a></li>
<li><a href="health/memory/"><img src="images/icons/overview/mempools.png" border="0" align="absmiddle" /> Memory</a></li>
<li><a href="health/storage/"><img src="images/icons/storage.png" border="0" align="absmiddle" /> Storage</a></li>
<li><hr width=140 /></li>
<li><a href="health/temperatures/"><img src="images/icons/temperature.png" border="0" align="absmiddle" /> Temperatures</a></li>
+1 -1
View File
@@ -13,7 +13,7 @@ if(!is_integer($syslog_iter/2)) { $bg_colour = $list_colour_a; } else { $bg_colo
echo("<td class=syslog width=125>" . $entry['date'] . "</td>");
# $entry['hostname'] = shorthost(gethostbyid($entry['host']), 20);
$entry['hostname'] = shorthost($entry['hostname'], 20);
if($_GET['page'] != "device") {
echo("<td width=160><strong>".generatedevicelink($entry)."</strong></td>");
+1 -1
View File
@@ -137,7 +137,7 @@ function popUp(URL) {
if(isset($_GET['page']) && !strstr("..", $_GET['page']) && is_file("pages/" . $_GET['page'] . ".php")) {
include("pages/" . $_GET['page'] . ".php");
} else {
if($config['front_page']) {
if(isset($config['front_page'])) {
include($config['front_page']);
} else {
include("pages/front/default.php");
+141 -57
View File
@@ -3,77 +3,97 @@
<tr>
<td bgcolor=#e5e5e5 valign=top>
<?php
# <table width=100% border=0><tr><td><div style="margin-bottom: 5px; font-size: 18px; font-weight: bold;">Devices with Alerts</div></td><td width=35 align=center><div class=tablehead>Host</div></td><td align=center width=35><div class=tablehead>Int</div></td><td align=center width=35><div class=tablehead>Srv</div></tr>
?>
<?php
$nodes = array();
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
while($device = mysql_fetch_array($sql)){
unset($already);
$i = 0;
while ($i <= count($nodes)) {
$thisnode = $device['device_id'];
if ($nodes[$i] == $thisnode) {
$already = "yes";
}
$i++;
}
if(!$already) { $nodes[] = $device['device_id']; }
}
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while($device = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffbbbb; margin: 4px;'>
<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span><br />
<span class=body-date-1>".truncate($device['location'], 20)."</span>
</center></div>");
if(devicepermitted($device['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #d0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffbbbb;'>
<strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span><br />
<span class=body-date-1>".truncate($device['location'], 35)."</span>
</div>");
}
}
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND D.status = '1' AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
if($config['warn']['ifdown']) {
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
while($interface = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generatedevicelink($interface, shorthost($interface['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span>
<strong>".generateiflink($interface, makeshortif($interface['ifDescr']))."</strong> <br />
<span class=body-date-1>".truncate($interface['ifAlias'], 20)."</span>
</center></div>");
if(interfacepermitted($interface['interface_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generatedevicelink($interface, shorthost($interface['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />
<strong>".generateiflink($interface, makeshortif($interface['ifDescr']))."</strong><br />
<span class=body-date-1>".truncate($interface['ifAlias'], 15)."</span>
</div>");
}
}
}
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND D.status = '1' AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while($service = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generatedevicelink($service, shorthost($service['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>
if(devicepermitted($service['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generatedevicelink($service, shorthost($service['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span><br />
<strong>".$service['service_type']."</strong><br />
<span class=body-date-1>".truncate($interface['ifAlias'], 20)."</span>
<span class=body-date-1>".truncate($interface['ifAlias'], 15)."</span>
</center></div>");
}
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE D.status = '1' AND bgpPeerState != 'established' AND B.device_id = D.device_id");
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id");
while($peer = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generatedevicelink($peer, shorthost($peer['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span>
<strong>".$peer['bgpPeerIdentifier']."</strong> <br />
if(devicepermitted($peer['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generatedevicelink($peer, shorthost($peer['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span><br />
<strong>".$peer['bgpPeerIdentifier']."</strong><br />
<span class=body-date-1>AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)."</span>
</center></div>");
</div>");
}
}
$sql = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND `uptime` < '84600'");
$sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'");
while($device = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ddffdd; margin: 4px;'>
<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />
<span class=body-date-1>".formatUptime($device['uptime'])."</span>
</center></div>");
if(devicepermitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>
<strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />
<span class=body-date-1>".formatUptime($device['attrib_value'])."</span>
</div>");
}
}
echo("
<div style='clear: both;'>$errorboxes</div> <div style='margin: 4px; clear: both;'>
<div style='clear: both;'>$errorboxes</div> <div style='margin: 0px; clear: both;'>
<h3>Recent Syslog Messages</h3>
");
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog AS S, devices AS D
WHERE S.device_id = D.device_id ORDER BY timestamp DESC LIMIT 20";
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
@@ -83,28 +103,92 @@ echo("</table>");
echo("</div>
</td>
<td bgcolor=#e5e5e5 width=275 valign=top>");
<td bgcolor=#e5e5e5 width=470 valign=top>");
/// this stuff can be customised to show whatever you want....
#if($_SESSION['userlevel'] >= '5') {
echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=bits&if=36".
"&from=".$day."&to=".$now."&width=400&height=150\'>', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 18px; font-weight: bold;'>Alpha Traffic</div>".
"<img src='graph.php?type=bits&if=36".
"&from=".$day."&to=".$now."&width=200&height=100'></a>");
$ports['fileserver'] = "78";
$ports['broadband'] = "228,251,182";
$ports['homeserver'] = "256,245,74";
echo("<div style='clear: both; margin-top: 10px;'></div>");
echo("<div style=' margin-bottom: 5px;'>");
if($ports['fileserver']) {
echo("<div style='width: 470px;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=multi_bits&ports=".$ports['fileserver']."&from=".$day."&to=".$now."&width=400&height=150\'>\
<img src=\'graph.php?type=multi_bits&ports=".$ports['fileserver']."&from=".$week."&to=".$now."&width=400&height=150\'>\
', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 16px; font-weight: bold; color: #555555;'>Main Fileserver</div>".
"<img src='graph.php?type=multi_bits&ports=".$ports['broadband'].
"&from=".$day."&to=".$now."&width=385&height=100&legend=no'></a></div>");
}
echo("</div>");
echo("<div style=' margin-bottom: 5px;'>");
echo("<div style='width: 235px; float: left;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=port_bits&port=182&from=".$day."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
<img src=\'graph.php?type=port_bits&port=182&from=".$week."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". "
<div style='font-size: 16px; font-weight: bold; color: #555555;'>NE61 Broadband</div>".
"<img src='graph.php?type=port_bits&port=182&from=".$day."&to=".$now."&width=155&height=100&inverse=0&legend=no'></a></div>");
echo("<div style='width: 235px; float: right;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=port_bits&port=74&from=".$day."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
<img src=\'graph.php?type=port_bits&port=74&from=".$week."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". "
<div style='font-size: 16px; font-weight: bold; color: #555555;'>NE61 Server</div>".
"<img src='graph.php?type=port_bits&port=74&from=".$day."&to=".$now."&width=155&height=100&inverse=0&legend=no'></a></div>");
echo("</div>");
echo("<div style=' margin-bottom: 5px;'>");
echo("<div style='width: 235px; float: left;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=port_bits&port=251&from=".$day."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
<img src=\'graph.php?type=port_bits&port=251&from=".$week."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". "
<div style='font-size: 16px; font-weight: bold; color: #555555;'>DE56 Broadband</div>".
"<img src='graph.php?type=port_bits&port=251&from=".$day."&to=".$now."&width=155&height=100&inverse=0&legend=no'></a></div>");
echo("<div style='width: 235px; float: right;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=port_bits&port=256&from=".$day."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
<img src=\'graph.php?type=port_bits&port=256&from=".$week."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". "
<div style='font-size: 16px; font-weight: bold; color: #555555;'>DE56 Server</div>".
"<img src='graph.php?type=port_bits&port=256&from=".$day."&to=".$now."&width=155&height=100&inverse=0&legend=no'></a></div>");
echo("</div>");
echo("<div style=' margin-bottom: 5px;'>");
echo("<div style='width: 235px; float: left;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=port_bits&port=228&from=".$day."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
<img src=\'graph.php?type=port_bits&port=228&from=".$week."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". "
<div style='font-size: 16px; font-weight: bold; color: #555555;'>DE24 Broadband</div>".
"<img src='graph.php?type=port_bits&port=228&from=".$day."&to=".$now."&width=155&height=100&inverse=0&legend=no'></a></div>");
echo("<div style='width: 235px; float: right;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=port_bits&port=245&from=".$day."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
<img src=\'graph.php?type=port_bits&port=245&from=".$week."&to=".$now."&width=400&height=150&inverse=0&legend=1\'>\
', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". "
<div style='font-size: 16px; font-weight: bold; color: #555555;'>DE24 Server</div>".
"<img src='graph.php?type=port_bits&port=245&from=".$day."&to=".$now."&width=155&height=100&inverse=0&legend=no'></a></div>");
echo("</div>");
echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=hrstorage&id=54".
"&from=".$day."&to=".$now."&width=400&height=150\'>', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 18px; font-weight: bold;'>Alpha Storage</div>".
"<img src='graph.php?type=hrstorage&id=54".
"&from=".$day."&to=".$now."&width=200&height=100'></a>");
#}
?>
</td>
+13
View File
@@ -2,6 +2,19 @@
## Common Functions
function device_by_id_cache($device_id)
{
global $device_cache;
if (is_array($device_cache[$device_id]))
{
$device = $device_cache[$device_id];
} else {
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device_id."'"));
$device_cache[$device_id] = $device;
}
return $device;
}
function truncate($substring, $max = 50, $rep = '...'){
if(strlen($substring) < 1){ $string = $rep; } else { $string = $substring; }
$leave = $max - strlen ($rep);
+4 -1
View File
@@ -27,7 +27,7 @@ $config['mono_font'] = "DejaVuSansMono";
$config['favicon'] = "favicon.ico";
$config['header_color'] = "#1F334E";
$config['page_refresh'] = "30"; ## Refresh the page every xx seconds
$config['frong_page'] = "default.php";
$config['frong_page'] = "pages/front/default.php";
$config['page_title'] = "ObserverNMS";
$config['syslog_age'] = "1 month";
$config['timestamp_format'] = 'd-m-Y H:i:s';
@@ -80,6 +80,9 @@ $config['ignore_mount_removable'] = 1; # Ignore removable disk storage
$config['ignore_mount_network'] = 1; # Ignore network mounted storage
$config['ignore_mount_optical'] = 1; # Ignore mounted optical discs
$config['device_traffic_iftype'] = array('/loopback/','/other/','/tunnel/','/virtual/','/mpls/');
$config['device_traffic_descr'] = array('/loopback/','/vlan/','/tunnel/','/:/');
# Sensors
$config['allow_entity_sensor']['amperes'] = 1;
-13
View File
@@ -25,19 +25,6 @@ require('collectd/config.php');
require('collectd/functions.php');
require('collectd/definitions.php');
function device_by_id_cache($device_id)
{
global $device_cache;
if (is_array($device_cache[$device_id]))
{
$device = $device_cache[$device_id];
} else {
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device_id."'"));
$device_cache[$device_id] = $device;
}
return $device;
}
function mac_clean_to_readable($mac)
{
$r = substr($mac, 0, 2);