mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
current support for webinterface
git-svn-id: http://www.observium.org/svn/observer/trunk@1127 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
23
html/includes/graphs/current.inc.php
Normal file
23
html/includes/graphs/current.inc.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include("common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$current = mysql_fetch_array(mysql_query("SELECT * FROM current where current_id = '".mres($_GET['id'])."'"));
|
||||
|
||||
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $current['device_id'] . "'"),0);
|
||||
|
||||
$current['current_descr_fixed'] = substr(str_pad($current['current_descr'], 28),0,28);
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("current-" . $current['current_descr'] . ".rrd");
|
||||
|
||||
$rrd_options .= " DEF:current=$rrd_filename:current:AVERAGE";
|
||||
$rrd_options .= " AREA:current#FFFF99";
|
||||
$rrd_options .= " LINE1.5:current#cc0000:'" . $current['current_descr_fixed']."'";
|
||||
$rrd_options .= " GPRINT:current:LAST:%3.0lfA";
|
||||
$rrd_options .= " GPRINT:current:MAX:%3.0lfA\\\\l";
|
||||
|
||||
?>
|
56
html/includes/graphs/device_current.inc.php
Normal file
56
html/includes/graphs/device_current.inc.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
include("common.inc.php");
|
||||
$device = device_by_id_cache($id);
|
||||
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM current where device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
while($current = mysql_fetch_array($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$hostname = gethostbyid($current['device_id']);
|
||||
|
||||
$descr = substr(str_pad($current['current_descr'], 15),0,15);
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("current-" . $current['current_descr'] . ".rrd");
|
||||
$current_id = $current['current_id'];
|
||||
|
||||
$rrd_options .= " DEF:current$current_id=$rrd_filename:current:AVERAGE";
|
||||
$rrd_options .= " LINE1:current$current_id#".$colour.":'" . $descr . "'";
|
||||
$rrd_options .= " GPRINT:current$current_id:AVERAGE:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:current$current_id:MIN:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:current$current_id:MAX:%5.2lfA\\\\l";
|
||||
|
||||
$iter++;
|
||||
}
|
||||
|
||||
|
||||
?>
|
@@ -44,6 +44,8 @@ $health = mysql_result(mysql_query("select count(*) from storage WHERE device_i
|
||||
mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(current_id) from current WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(freq_id) from frequencies WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(volt_id) from voltage WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(fan_id) from fanspeed WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
|
||||
|
@@ -7,6 +7,7 @@ $processor = mysql_result(mysql_query("select count(*) from processors WHERE de
|
||||
$fans = mysql_result(mysql_query("select count(*) from fanspeed WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$volts = mysql_result(mysql_query("select count(*) from voltage WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$freqs = mysql_result(mysql_query("select count(*) from frequency WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$current = mysql_result(mysql_query("select count(*) from current WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
|
||||
if ($processor) { $datas[] = 'processors'; }
|
||||
if ($memory) { $datas[] = 'memory'; }
|
||||
@@ -15,6 +16,7 @@ if ($temperatures) { $datas[] = 'temperatures'; }
|
||||
if ($fans) { $datas[] = 'fanspeeds'; }
|
||||
if ($volts) { $datas[] = 'voltages'; }
|
||||
if ($freqs) { $datas[] = 'frequencies'; }
|
||||
if ($current) { $datas[] = 'current'; }
|
||||
|
||||
$type_text['temperatures'] = "Temperatures";
|
||||
$type_text['memory'] = "Memory Pools";
|
||||
@@ -23,6 +25,7 @@ $type_text['processors'] = "Processor Usage";
|
||||
$type_text['voltages'] = "Voltages";
|
||||
$type_text['fanspeeds'] = "Fan Speeds";
|
||||
$type_text['frequencies'] = "Frequencies";
|
||||
$type_text['current'] = "Current";
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
|
@@ -81,6 +81,7 @@ include("overview/temperatures.inc.php");
|
||||
include("overview/fanspeeds.inc.php");
|
||||
include("overview/voltages.inc.php");
|
||||
include("overview/frequencies.inc.php");
|
||||
include("overview/current.inc.php");
|
||||
|
||||
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
|
||||
echo("<p style='padding: 0px 5px 5px;' class=sectionhead><img align='absmiddle' src='".$config['base_url']."/images/16/report.png'> Recent Events</p>");
|
||||
|
45
html/pages/device/overview/current.inc.php
Normal file
45
html/pages/device/overview/current.inc.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
unset($current_seperator);
|
||||
if(mysql_result(mysql_query("SELECT count(current_id) from current WHERE device_id = '" . $device['device_id'] . "'"),0)) {
|
||||
$total = mysql_result(mysql_query("SELECT count(current_id) from current WHERE device_id = '" . $device['device_id'] . "'"),0);
|
||||
$rows = round($total / 2,0);
|
||||
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
|
||||
echo("<p style='padding: 0px 5px 5px;' class=sectionhead><img align='absmiddle' src='".$config['base_url']."/images/icons/current.png'> Current</p>");
|
||||
$i = '1';
|
||||
$currents = mysql_query("SELECT * FROM current WHERE device_id = '" . $device['device_id'] . "'");
|
||||
echo("<table width=100% valign=top>");
|
||||
echo("<tr><td width=50%>");
|
||||
echo("<table width=100% cellspacing=0 cellpadding=2>");
|
||||
while($current = mysql_fetch_array($currents)) {
|
||||
if(is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
$graph_colour = str_replace("#", "", $row_colour);
|
||||
|
||||
$current_day = "graph.php?id=" . $current['current_id'] . "&type=current&from=$day&to=$now&width=300&height=100";
|
||||
$current_week = "graph.php?id=" . $current['current_id'] . "&type=current&from=$week&to=$now&width=300&height=100";
|
||||
$current_month = "graph.php?id=" . $current['current_id'] . "&type=current&from=$month&to=$now&width=300&height=100";
|
||||
$current_year = "graph.php?id=" . $current['current_id'] . "&type=current&from=$year&to=$now&width=300&height=100";
|
||||
$current_minigraph = "<img src='graph.php?id=" . $current['current_id'] . "&type=current&from=$day&to=$now&width=80&height=20&bg=$graph_colour' align='absmiddle'>";
|
||||
|
||||
$current_link = "<a href='/device/".$device['device_id']."/health/currentuencies/' onmouseover=\"return ";
|
||||
$current_link .= "overlib('<div class=list-large>".$device['hostname']." - ".$current['current_descr'];
|
||||
$current_link .= "</div><div style=\'width: 750px\'><img src=\'$current_day\'><img src=\'$current_week\'><img src=\'$current_month\'><img src=\'$current_year\'></div>', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >";
|
||||
|
||||
$current_link_c = $current_link . "<span " . ($current['current_current'] < $current['current_limit_low'] || $current['current_current'] > $current['current_limit'] ? "style='color: red'" : '') . '>' . $current['current_current'] . "A</span></a>";
|
||||
$current_link_b = $current_link . $current_minigraph . "</a>";
|
||||
$current_link_a = $current_link . $current['current_descr'] . "</a>";
|
||||
|
||||
$current['current_descr'] = truncate($current['current_descr'], 25, '');
|
||||
echo("<tr bgcolor='$row_colour'><td class=tablehead><strong>$current_link_a</strong></td><td width=80 align=right class=tablehead>$current_link_b<td width=80 align=right class=tablehead>$current_link_c</td></tr>");
|
||||
if($i == $rows) { echo("</table></td><td valign=top><table width=100% cellspacing=0 cellpadding=2>"); }
|
||||
$i++;
|
||||
}
|
||||
echo("</table>");
|
||||
echo("</td></tr>");
|
||||
echo("</table>");
|
||||
echo("</div>");
|
||||
}
|
||||
|
||||
|
||||
?>
|
Reference in New Issue
Block a user