more crap from falz, something about alerts and... TLDR

git-svn-id: http://www.observium.org/svn/observer/trunk@2078 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-04-13 16:37:29 +00:00
parent b593df2549
commit e7e2ec8213
6 changed files with 266 additions and 40 deletions

View File

@@ -76,20 +76,23 @@ if (isset($config['enable_bgp']) && $config['enable_bgp'])
} }
} }
if ($_SESSION['userlevel'] == '10') if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
{ {
$sql = mysql_query("SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime < '84600' AND D.ignore = 0"); if ($_SESSION['userlevel'] == '10')
} else { {
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime < '84600' AND D.ignore = 0"); $sql = mysql_query("SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0");
} } else {
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime < '" .
while ($device = mysql_fetch_assoc($sql)) $config['uptime_warning'] . "' AND D.ignore = 0");
{ }
generate_front_box("#aaffaa", "<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #009;'>Device<br />Rebooted</span><br />
<span class=body-date-1>".formatUptime($device['uptime'], 'short')."</span>
</center>");
while ($device = mysql_fetch_assoc($sql))
{
generate_front_box("#aaffaa", "<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #009;'>Device<br />Rebooted</span><br />
<span class=body-date-1>".formatUptime($device['uptime'], 'short')."</span>
</center>");
}
} }
if ($config['enable_syslog']) if ($config['enable_syslog'])
@@ -140,4 +143,4 @@ if ($config['enable_syslog'])
echo("</div>"); echo("</div>");
?> ?>

View File

@@ -78,16 +78,20 @@ while ($peer = mysql_fetch_array($sql))
} }
} }
$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'"); if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
while ($device = mysql_fetch_array($sql))
{ {
if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime") $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE
A.attrib_value < '" . $config['uptime_warning'] . "' 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='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'> if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime")
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br /> {
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br /> 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;'>
<span class=body-date-1>".formatUptime($device['attrib_value'])."</span> <strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
</div>"); <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>");
}
} }
} }

View File

@@ -74,15 +74,17 @@ while ($peer = mysql_fetch_assoc($sql)){
} }
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '84600'"); if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
while ($device = mysql_fetch_assoc($sql)){ {
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'");
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ddffdd; margin: 4px;'> while ($device = mysql_fetch_assoc($sql)){
<center><strong>".generate_device_link($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>
</center></div>");
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ddffdd; margin: 4px;'>
<center><strong>".generate_device_link($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>
</center></div>");
}
} }
echo(" echo("

View File

@@ -6,7 +6,13 @@
$nodes = array(); $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'"); $uptimesql = "";
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
{
$uptimesql = " AND A.attrib_value < '" . $config['uptime_warning'] . "'";
}
$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' " . $uptimesql);
while ($device = mysql_fetch_assoc($sql)){ while ($device = mysql_fetch_assoc($sql)){
unset($already); unset($already);
@@ -73,15 +79,18 @@ while ($peer = mysql_fetch_assoc($sql)){
} }
} }
$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'"); if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
while ($device = mysql_fetch_assoc($sql)){ {
if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime") { $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'");
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;'> while ($device = mysql_fetch_assoc($sql)){
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br /> if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") {
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br /> 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;'>
<span class=body-date-1>".formatUptime($device['attrib_value'])."</span> <strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
</div>"); <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>");
}
}
} }

View File

@@ -0,0 +1,207 @@
<table border=0 cellpadding=10 cellspacing=10 width=100%>
<tr>
<td bgcolor=#e5e5e5 valign=top>
<?php
$nodes = array();
$uptimesql = "";
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
{
$uptimesql = " AND A.attrib_value < '" . $config['uptime_warning'] . "'";
}
$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' " . $uptimesql);
while ($device = mysql_fetch_assoc($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_assoc($sql)){
if (device_permitted($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>".generate_device_link($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>");
}
}
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_assoc($sql)){
if (port_permitted($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>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />
<strong>".generate_port_link($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 service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while ($service = mysql_fetch_assoc($sql)){
if (device_permitted($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>".generate_device_link($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'], 15)."</span>
</center></div>");
}
}
$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_assoc($sql)){
if (device_permitted($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>".generate_device_link($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>
</div>");
}
}
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
{
$sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'");
while ($device = mysql_fetch_assoc($sql)){
if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $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>".generate_device_link($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: 0px; clear: both;'>
<h3>Recent Syslog Messages</h3>
");
$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_assoc($query)) { include("includes/print-syslog.inc.php"); }
echo("</table>");
echo("</div>
</td>
<td bgcolor=#e5e5e5 width=470 valign=top>");
/// this stuff can be customised to show whatever you want....
if ($_SESSION['userlevel'] >= '5')
{
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
$query = mysql_query($sql);
unset ($seperator);
while ($interface = mysql_fetch_assoc($query)) {
$ports['transit'] .= $seperator . $interface['interface_id'];
$seperator = ",";
}
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
$query = mysql_query($sql);
unset ($seperator);
while ($interface = mysql_fetch_assoc($query)) {
$ports['peering'] .= $seperator . $interface['interface_id'];
$seperator = ",";
}
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
$query = mysql_query($sql);
unset ($seperator);
while ($interface = mysql_fetch_assoc($query)) {
$ports['core'] .= $seperator . $interface['interface_id'];
$seperator = ",";
}
echo("<div style=' margin-bottom: 5px;'>");
if ($ports['peering'] && $ports['transit']) {
echo("<div style='width: 235px; '>
<a href='internet/' onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits_duo&amp;id=".$ports['peering']."&amp;idb=".$ports['transit']."&amp;from=".$day."&amp;to=".$now."&amp;width=400&amp;height=150\'>\
<img src=\'graph.php?type=multiport_bits_duo&amp;id=".$ports['peering']."&amp;idb=".$ports['transit']."&amp;from=".$week."&amp;to=".$now."&amp;width=400&amp;height=150\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 16px; font-weight: bold; color: #555555;'>Aggregate Internet Traffic</div>".
"<img src='graph.php?type=multiport_bits_duo&amp;id=".$ports['peering']."&amp;idb=".$ports['transit'].
"&amp;from=".$day."&amp;to=".$now."&amp;width=385&amp;height=100&amp;legend=no'></a></div>");
}
echo("</div>");
echo("<div style=' margin-bottom: 5px;'>");
if ($ports['transit']) {
echo("<div style='width: 235px; float: left;'>
<a href='iftype/transit/' onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits&amp;id=".$ports['transit']."&amp;from=".$day."&amp;to=".$now."&amp;width=400&amp;height=150\'>\
<img src=\'graph.php?type=multiport_bits&amp;id=".$ports['transit']."&amp;from=".$week."&amp;to=".$now."&amp;width=400&amp;height=150\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 16px; font-weight: bold; color: #555555;'>Internet Transit</div>".
"<img src='graph.php?type=multiport_bits&amp;id=".$ports['transit'].
"&amp;from=".$day."&amp;to=".$now."&amp;width=155&amp;height=100&amp;legend=no'></a></div>");
}
if ($ports['peering']) {
echo("<div style='width: 235px; float: right;'>
<a href='iftype/peering/' onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits&amp;id=".$ports['peering']."&amp;from=".$day."&amp;to=".$now."&amp;width=400&amp;height=150\'>\
<img src=\'graph.php?type=multiport_bits&amp;id=".$ports['peering']."&amp;from=".$week."&amp;to=".$now."&amp;width=400&amp;height=150\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 16px; font-weight: bold; color: #555555;'>Internet Peering</div>".
"<img src='graph.php?type=multiport_bits&amp;id=".$ports['peering'].
"&amp;from=".$day."&amp;to=".$now."&amp;width=155&amp;height=100&amp;legend=no'></a></div>");
}
if ($ports['core']) {
echo("<div style='width: 235px;'>
<a href='iftype/core/' onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits&amp;id=".$ports['core']."&amp;from=".$day."&amp;to=".$now."&amp;width=400&amp;height=150\'>\
<img src=\'graph.php?type=multiport_bits&amp;id=".$ports['core']."&amp;from=".$week."&amp;to=".$now."&amp;width=400&amp;height=150\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 16px; font-weight: bold; color: #555555;'>Core Traffic</div>".
"<img src='graph.php?type=multiport_bits&amp;id=".$ports['core'].
"&amp;from=".$day."&amp;to=".$now."&amp;width=385&amp;height=100&amp;legend=no'></a></div>");
}
echo("</div>");
}
?>
</td>
</tr>
<tr>
</tr></table>

View File

@@ -41,7 +41,7 @@ $config['mono_font'] = "DejaVuSansMono";
$config['favicon'] = "images/observium-icon.png"; $config['favicon'] = "images/observium-icon.png";
$config['header_color'] = "#1F334E"; $config['header_color'] = "#1F334E";
$config['page_refresh'] = "300"; ## Refresh the page every xx seconds $config['page_refresh'] = "300"; ## Refresh the page every xx seconds
$config['frong_page'] = "pages/front/default.php"; $config['front_page'] = "pages/front/default.php";
$config['page_title'] = "Observium :: Network Observation and Monitoring"; $config['page_title'] = "Observium :: Network Observation and Monitoring";
$config['timestamp_format'] = 'd-m-Y H:i:s'; $config['timestamp_format'] = 'd-m-Y H:i:s';
$config['page_gen'] = 1; $config['page_gen'] = 1;
@@ -77,6 +77,7 @@ $config['discover_services'] = false; ## Autodiscover services via SNMP on
$config['alerts']['email']['default'] = NULL; ## Default alert recipient $config['alerts']['email']['default'] = NULL; ## Default alert recipient
$config['alerts']['email']['default_only'] = FALSE; ## Only use default recipient $config['alerts']['email']['default_only'] = FALSE; ## Only use default recipient
$config['alerts']['email']['enable'] = TRUE; ## Enable email alerts $config['alerts']['email']['enable'] = TRUE; ## Enable email alerts
$config['uptime_warning'] = "84600"; ## Time in seconds to display a "Device Rebooted" Alert. 0 to disable warnings.
### Cosmetics ### Cosmetics