mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
adding new /health/ pages, need cleaning up, need option to enable/disable graphs (right side 'toggle'?)
git-svn-id: http://www.observium.org/svn/observer/trunk@1062 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -48,13 +48,14 @@ $health = mysql_result(mysql_query("select count(*) from storage WHERE device_i
|
||||
if($health) {
|
||||
echo('<li class="' . $select['health'] . '">
|
||||
<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/health/">
|
||||
<img src="images/16/chart_curve.png" align="absmiddle" border="0" /> Health
|
||||
<img src="images/icons/sensors.png" align="absmiddle" border="0" /> Health
|
||||
</a>
|
||||
</li>');
|
||||
}
|
||||
|
||||
#$cisco_sensors = mysql_result(mysql_query("SELECT count(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entSensorType != '' AND entSensorType NOT LIKE 'No%'"),0);
|
||||
### This needs to die, rolled into generic sensors! (still need to implement booleans, tx/rx powers and currents)
|
||||
|
||||
#$cisco_sensors = mysql_result(mysql_query("SELECT count(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entSensorType != '' AND entSensorType NOT LIKE 'No%'"),0);
|
||||
#if($cisco_sensors) {
|
||||
# echo('<li class="' . $select['ciscosensors'] . '">
|
||||
# <a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ciscosensors/">
|
||||
@@ -104,6 +105,9 @@ if($config['enable_bgp'] && $device['bgpLocalAs']) {
|
||||
</li>');
|
||||
}
|
||||
|
||||
### This probably needs to die? DEATH TO NAGIOS!
|
||||
|
||||
|
||||
#if(@mysql_result(mysql_query("SELECT count(*) FROM nagios_hosts WHERE address = '".$device['hostname']."'", $nagios_link), 0) > '0') {
|
||||
# echo('<li class="' . $select['nagios'] . '">
|
||||
# <a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/nagios/">
|
||||
|
@@ -10,7 +10,11 @@
|
||||
|
||||
$mini_url = $config['base_url'] . "/graph.php?id=".$proc['processor_id']."&type=processor&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
|
||||
|
||||
|
||||
$text_descr = $proc['processor_descr'];
|
||||
$text_descr = str_replace("Routing Processor", "RP", $text_descr);
|
||||
$text_descr = str_replace("Switching Processor", "SP", $text_descr);
|
||||
$text_descr = str_replace("Sub-Module", "Module ", $text_descr);
|
||||
$text_descr = str_replace("DFC Card", "DFC", $text_descr);
|
||||
|
||||
$proc_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$text_descr;
|
||||
$proc_popup .= "</div><img src=\'graph.php?id=" . $proc['proc_id'] . "&type=proc&from=$month&to=$now&width=400&height=125\'>";
|
||||
@@ -24,7 +28,8 @@
|
||||
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
|
||||
} else { $left_background='9abf5b'; $right_background='bbd392'; }
|
||||
|
||||
echo("<tr bgcolor=$row_colour><td class=tablehead><a href='".$proc_url."' $proc_popup>" . $text_descr . "</a></td>
|
||||
echo("<tr bgcolor=$row_colour>
|
||||
<td class=tablehead><a href='".$proc_url."' $proc_popup>" . $text_descr . "</a></td>
|
||||
<td width=90><a href='".$proc_url."' $proc_popup><img src='$mini_url'></a></td>
|
||||
<td width=200><a href='".$proc_url."' $proc_popup>
|
||||
".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $left_background, (100 - $perc)."%" , "ffffff", $right_background)."
|
||||
|
@@ -18,6 +18,8 @@ if(mysql_result(mysql_query("SELECT count(*) from processors WHERE device_id = '
|
||||
|
||||
$mini_url = $config['base_url'] . "/graph.php?id=".$proc['processor_id']."&type=processor&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
|
||||
|
||||
## REPLACE THIS SHITTY CODE. IT IS ALSO ELSEWHERE.
|
||||
|
||||
$text_descr = $proc['processor_descr'];
|
||||
$text_descr = str_replace("Routing Processor", "RP", $text_descr);
|
||||
$text_descr = str_replace("Switching Processor", "SP", $text_descr);
|
||||
|
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
$datas = array('Temperatures', 'Voltages', 'Fanspeeds');
|
||||
$datas = array('Processors','Memory','Storage','Temperatures', 'Voltages', 'Fanspeeds');
|
||||
|
||||
if(!$_GET['opta']) { $_GET['opta'] = "processors"; }
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
@@ -10,7 +12,7 @@ foreach ($datas as $texttype) {
|
||||
if (!isset($_GET['opta'])) { $_GET['opta'] = $type; }
|
||||
echo($sep);
|
||||
if ($_GET['opta'] == $type) { echo("<strong>"); }
|
||||
echo("<a href='".$config['base_url']."/sensors/" . $type . "/'> " . $texttype ."</a>\n");
|
||||
echo("<a href='".$config['base_url']."/health/" . $type . "/'> " . $texttype ."</a>\n");
|
||||
if ($_GET['opta'] == $type) { echo("</strong>"); }
|
||||
$sep = ' | ';
|
||||
}
|
||||
@@ -22,13 +24,16 @@ print_optionbar_end();
|
||||
|
||||
switch ($_GET['opta'])
|
||||
{
|
||||
case 'processors':
|
||||
case 'memory':
|
||||
case 'storage':
|
||||
case 'temperatures':
|
||||
case 'voltages':
|
||||
case 'fanspeeds':
|
||||
include('pages/sensors/'.$_GET['opta'].'.php');
|
||||
include('pages/health/'.$_GET['opta'].'.inc.php');
|
||||
break;
|
||||
default:
|
||||
include('pages/sensors/temperatures.php');
|
||||
include('pages/health/temperatures.inc.php');
|
||||
break;
|
||||
}
|
||||
|
77
html/pages/health/memory.inc.php
Normal file
77
html/pages/health/memory.inc.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
echo("<div style='margin-top: 5px; padding: 0px;'>");
|
||||
echo("<table width=100% cellpadding=6 cellspacing=0>");
|
||||
$i = '1';
|
||||
$mempools = mysql_query("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id");
|
||||
while($mempool = mysql_fetch_array($mempools)) {
|
||||
if(devicepermitted($mempool['device_id'])) {
|
||||
if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
$proc_url = "?page=device/".$device['device_id']."/health/memory/";
|
||||
|
||||
$text_descr = $mempool['mempool_descr'];
|
||||
|
||||
$mempool_url = "/device/".$device['device_id']."/health/memory/";
|
||||
$mini_url = $config['base_url'] . "/graph.php?id=".$mempool['mempool_id']."&type=mempool&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
|
||||
|
||||
$mempool_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$text_descr;
|
||||
$mempool_popup .= "</div><img src=\'graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$month&to=$now&width=400&height=125\'>";
|
||||
$mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"";
|
||||
|
||||
$total = formatStorage($mempool['mempool_total']);
|
||||
$used = formatStorage($mempool['mempool_used']);
|
||||
$free = formatStorage($mempool['mempool_free']);
|
||||
|
||||
$perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100);
|
||||
|
||||
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
|
||||
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
|
||||
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
|
||||
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
|
||||
} else { $left_background='9abf5b'; $right_background='bbd392'; }
|
||||
|
||||
echo("<tr bgcolor=$row_colour>
|
||||
<td>".generatedevicelink($mempool)."</td>
|
||||
<td class=tablehead><a href='".$mempool_url."' $mempool_popup>" . $text_descr . "</a></td>
|
||||
<td width=90><a href='".$mempool_url."' $mempool_popup><img src='$mini_url'></a></td>
|
||||
<td width=200><a href='".$mempool_url."' $mempool_popup>
|
||||
".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free , "ffffff", $right_background)."
|
||||
</a></td>
|
||||
<td width=50>".$perc."%</td>
|
||||
</tr>");
|
||||
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=5>");
|
||||
|
||||
$daily_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$day&to=$now&width=211&height=100";
|
||||
$daily_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$day&to=$now&width=400&height=150";
|
||||
|
||||
$weekly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$week&to=$now&width=211&height=100";
|
||||
$weekly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$week&to=$now&width=400&height=150";
|
||||
|
||||
$monthly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$month&to=$now&width=211&height=100";
|
||||
$monthly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$month&to=$now&width=400&height=150";
|
||||
|
||||
$yearly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$year&to=$now&width=211&height=100";
|
||||
$yearly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$year&to=$now&width=400&height=150";
|
||||
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$daily_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$weekly_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$monthly_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$yearly_graph' border=0></a>");
|
||||
echo("</td></tr>");
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
echo("</table>");
|
||||
echo("</div>");
|
||||
|
||||
|
||||
?>
|
||||
|
78
html/pages/health/processors.inc.php
Normal file
78
html/pages/health/processors.inc.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
echo("<div style='margin-top: 5px; padding: 0px;'>");
|
||||
echo("<table width=100% cellpadding=6 cellspacing=0>");
|
||||
$i = '1';
|
||||
$procs = mysql_query("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id");
|
||||
while($proc = mysql_fetch_array($procs)) {
|
||||
|
||||
if(devicepermitted($proc['device_id'])) {
|
||||
|
||||
$device = $proc;
|
||||
|
||||
$text_descr = $proc['processor_descr'];
|
||||
$text_descr = str_replace("Routing Processor", "RP", $text_descr);
|
||||
$text_descr = str_replace("Switching Processor", "SP", $text_descr);
|
||||
$text_descr = str_replace("Sub-Module", "Module ", $text_descr);
|
||||
$text_descr = str_replace("DFC Card", "DFC", $text_descr);
|
||||
|
||||
|
||||
$proc_url = "?page=device/".$device['device_id']."/health/processors/";
|
||||
|
||||
$mini_url = $config['base_url'] . "/graph.php?id=".$proc['processor_id']."&type=processor&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
|
||||
|
||||
$proc_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$text_descr;
|
||||
$proc_popup .= "</div><img src=\'graph.php?id=" . $proc['proc_id'] . "&type=proc&from=$month&to=$now&width=400&height=125\'>";
|
||||
$proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"";
|
||||
|
||||
$perc = round($proc['processor_usage']);
|
||||
|
||||
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
|
||||
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
|
||||
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
|
||||
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
|
||||
} else { $left_background='9abf5b'; $right_background='bbd392'; }
|
||||
|
||||
echo("<tr bgcolor=$row_colour>
|
||||
<td>".generatedevicelink($proc)."</td>
|
||||
|
||||
<td class=tablehead><a href='".$proc_url."' $proc_popup>" . $text_descr . "</a></td>
|
||||
<td width=90><a href='".$proc_url."' $proc_popup><img src='$mini_url'></a></td>
|
||||
<td width=200><a href='".$proc_url."' $proc_popup>
|
||||
".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $left_background, (100 - $perc)."%" , "ffffff", $right_background)."
|
||||
</a></td>
|
||||
</tr>");
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=5>");
|
||||
|
||||
$daily_graph = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$day&to=$now&width=211&height=100";
|
||||
$daily_url = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$day&to=$now&width=400&height=150";
|
||||
|
||||
$weekly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$week&to=$now&width=211&height=100";
|
||||
$weekly_url = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$week&to=$now&width=400&height=150";
|
||||
|
||||
$monthly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$month&to=$now&width=211&height=100";
|
||||
$monthly_url = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$month&to=$now&width=400&height=150";
|
||||
|
||||
$yearly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$year&to=$now&width=211&height=100";
|
||||
$yearly_url = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$year&to=$now&width=400&height=150";
|
||||
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$daily_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$weekly_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$monthly_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$yearly_graph' border=0></a>");
|
||||
echo("</td></tr>");
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
}
|
||||
echo("</table>");
|
||||
echo("</div>");
|
||||
|
||||
|
||||
?>
|
81
html/pages/health/storage.inc.php
Normal file
81
html/pages/health/storage.inc.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
|
||||
$sql = "SELECT * FROM `storage` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY D.hostname, S.storage_descr";
|
||||
|
||||
$query = mysql_query($sql);
|
||||
|
||||
echo("<div style='padding: 5px;'>
|
||||
<table width=100% cellspacing=0 cellpadding=2>");
|
||||
|
||||
echo("<tr class=tablehead>
|
||||
<th width=280>Device</th>
|
||||
<th>Storage</th>
|
||||
<th width=100></th>
|
||||
<th width=280>Usage</th>
|
||||
<th width=50>Used</th>
|
||||
</tr>");
|
||||
|
||||
$row = 1;
|
||||
|
||||
while($drive = mysql_fetch_array($query)) {
|
||||
|
||||
if(devicepermitted($drive['device_id'])){
|
||||
|
||||
$skipdrive = 0;
|
||||
|
||||
if ($drive["os"] == "junos") {
|
||||
foreach ($config['ignore_junos_os_drives'] as $jdrive) {
|
||||
if (preg_match($jdrive, $drive["storage_descr"])) {
|
||||
$skipdrive = 1;
|
||||
}
|
||||
}
|
||||
$drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]);
|
||||
}
|
||||
|
||||
if ($drive['os'] == "freebsd") {
|
||||
foreach ($config['ignore_bsd_os_drives'] as $jdrive) {
|
||||
if (preg_match($jdrive, $drive["storage_descr"])) {
|
||||
$skipdrive = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($skipdrive) { continue; }
|
||||
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
$perc = round($drive['storage_perc'], 0);
|
||||
$total = formatStorage($drive['storage_size']);
|
||||
$free = formatStorage($drive['storage_free']);
|
||||
$used = formatStorage($drive['storage_used']);
|
||||
|
||||
$store_url = "graph.php?id=" . $drive['storage_id'] . "&type=storage&from=$month&to=$now&width=400&height=125";
|
||||
$store_popup = "onmouseover=\"return overlib('<img src=\'$store_url\'>', LEFT);\" onmouseout=\"return nd();\"";
|
||||
|
||||
$mini_graph = $config['base_url'] . "/graph.php?id=".$drive['storage_id']."&type=storage&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
|
||||
|
||||
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
|
||||
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
|
||||
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
|
||||
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
|
||||
} else { $left_background='9abf5b'; $right_background='bbd392'; }
|
||||
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><td>" . generatedevicelink($drive) . "</td><td class=tablehead>" . $drive['storage_descr'] . "</td>
|
||||
<td><img src='$mini_graph'></td>
|
||||
<td>
|
||||
<a href='#' $store_popup>".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, formatStorage($free), "ffffff", $right_background)."</a>
|
||||
</td><td>$perc"."%</td></tr>");
|
||||
|
||||
|
||||
$row++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo("</table></div>");
|
||||
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user