mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 00:24:21 +02:00
sensors table, with humidity as its first consumer - akcp humidity support implemented
git-svn-id: http://www.observium.org/svn/observer/trunk@1249 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
$temperatures = mysql_result(mysql_query("select count(*) from temperature WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$humidity = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='humidity' AND device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$storage = mysql_result(mysql_query("select count(*) from storage WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$diskio = mysql_result(mysql_query("select count(*) from ucd_diskio WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$memory = mysql_result(mysql_query("select count(*) from mempools WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
@@ -16,6 +17,7 @@ if ($memory) { $datas[] = 'memory'; }
|
||||
if ($storage) { $datas[] = 'storage'; }
|
||||
if ($diskio) { $datas[] = 'diskio'; }
|
||||
if ($temperatures) { $datas[] = 'temperatures'; }
|
||||
if ($humidity) { $datas[] = 'humidity'; }
|
||||
if ($fans) { $datas[] = 'fanspeeds'; }
|
||||
if ($volts) { $datas[] = 'voltages'; }
|
||||
if ($freqs) { $datas[] = 'frequencies'; }
|
||||
@@ -24,6 +26,7 @@ if ($current) { $datas[] = 'current'; }
|
||||
|
||||
$type_text['overview'] = "Overview";
|
||||
$type_text['temperatures'] = "Temperatures";
|
||||
$type_text['humidity'] = "Humidity";
|
||||
$type_text['memory'] = "Memory Pools";
|
||||
$type_text['storage'] = "Disk Usage";
|
||||
$type_text['diskio'] = "Disk IO";
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
$sql = "SELECT * FROM `sensors` WHERE sensor_class='humidity' AND device_id = '" . $_GET[id] . "' ORDER BY sensor_descr";
|
||||
$query = mysql_query($sql);
|
||||
|
||||
echo("<table cellspacing=0 cellpadding=5 width=100%>");
|
||||
|
||||
$row = 1;
|
||||
|
||||
while($humidity = mysql_fetch_array($query)) {
|
||||
|
||||
if(!is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
echo("<tr class=list-large style=\"background-color: $row_colour; padding: 5px;\">
|
||||
<td width=350>" . $humidity['sensor_descr'] . "</td>
|
||||
<td>" . $humidity['sensor_current'] . " %</td>
|
||||
<td>" . $humidity['sensor_limit'] . " %</td>
|
||||
<td>" . $humidity['sensor_notes'] . "</td>
|
||||
</tr>\n");
|
||||
echo("<tr bgcolor=$row_colour><td colspan='4'>");
|
||||
|
||||
$graph_type = "humidity";
|
||||
|
||||
// start humidity graphs
|
||||
|
||||
$daily_humidity = "graph.php?id=" . $humidity['sensor_id'] . "&type=$graph_type&from=$day&to=$now&width=211&height=100";
|
||||
$daily_url = "graph.php?id=" . $humidity['sensor_id'] . "&type=$graph_type&from=$day&to=$now&width=400&height=150";
|
||||
|
||||
$weekly_humidity = "graph.php?id=" . $humidity['sensor_id'] . "&type=$graph_type&from=$week&to=$now&width=211&height=100";
|
||||
$weekly_url = "graph.php?id=" . $humidity['sensor_id'] . "&type=$graph_type&from=$week&to=$now&width=400&height=150";
|
||||
|
||||
$monthly_humidity = "graph.php?id=" . $humidity['sensor_id'] . "&type=$graph_type&from=$month&to=$now&width=211&height=100";
|
||||
$monthly_url = "graph.php?id=" . $humidity['sensor_id'] . "&type=$graph_type&from=$month&to=$now&width=400&height=150";
|
||||
|
||||
$yearly_humidity = "graph.php?id=" . $humidity['sensor_id'] . "&type=$graph_type&from=$year&to=$now&width=211&height=100";
|
||||
$yearly_url = "graph.php?id=" . $humidity['sensor_id'] . "&type=$graph_type&from=$year&to=$now&width=400&height=150";
|
||||
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$daily_humidity' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$weekly_humidity' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$monthly_humidity' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$yearly_humidity' border=0></a>");
|
||||
|
||||
|
||||
echo("</td></tr>");
|
||||
|
||||
|
||||
$row++;
|
||||
|
||||
}
|
||||
|
||||
echo("</table>");
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -91,6 +91,7 @@ include("overview/mempools.inc.php");
|
||||
#include("overview/hrStorage.inc.php");
|
||||
include("overview/storage.inc.php");
|
||||
include("overview/temperatures.inc.php");
|
||||
include("overview/humidity.inc.php");
|
||||
include("overview/fanspeeds.inc.php");
|
||||
include("overview/voltages.inc.php");
|
||||
include("overview/frequencies.inc.php");
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
unset($humidity_seperator);
|
||||
if($total = mysql_result(mysql_query("SELECT count(sensor_id) from sensors WHERE sensor_class='humidity' AND 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/humidity.png'> Humidity</p>");
|
||||
$i = '1';
|
||||
$humiditys = mysql_query("SELECT * FROM sensors WHERE sensor_class='humidity' AND device_id = '" . $device['device_id'] . "' ORDER BY sensor_index");
|
||||
echo('<table width="100%" valign="top">');
|
||||
echo('<tr><td width="50%">');
|
||||
echo('<table width="100%" cellspacing="0" cellpadding="2">');
|
||||
while($humidity = mysql_fetch_array($humiditys)) {
|
||||
if(is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
$graph_colour = str_replace("#", "", $row_colour);
|
||||
|
||||
$humidity_perc = $humidity['sensor_current'] / $humidity['sensor_limit'] * 100;
|
||||
$humidity_colour = percent_colour($humidity_perc);
|
||||
$humidity_day = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$day&to=$now&width=300&height=100";
|
||||
$humidity_week = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$week&to=$now&width=300&height=100";
|
||||
$humidity_month = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$month&to=$now&width=300&height=100";
|
||||
$humidity_year = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$year&to=$now&width=300&height=100";
|
||||
$humidity_minigraph = "<img src='graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$day&to=$now&width=80&height=20&bg=$graph_colour' align='absmiddle'>";
|
||||
|
||||
$humidity_link = "<a href='/device/".$device['device_id']."/health/humiditys/' onmouseover=\"return ";
|
||||
$humidity_link .= "overlib('<div class=list-large>".$device['hostname']." - ".$humidity['sensor_descr'];
|
||||
$humidity_link .= "</div><div style=\'width: 750px\'><img src=\'$humidity_day\'><img src=\'$humidity_week\'><img src=\'$humidity_month\'><img src=\'$humidity_year\'></div>', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >";
|
||||
|
||||
$humidity_link_c = $humidity_link . "<span style='color: $humidity_colour'>" . round($humidity['sensor_current'],0) . "%</span></a>";
|
||||
$humidity_link_b = $humidity_link . $humidity_minigraph . "</a>";
|
||||
$humidity_link_a = $humidity_link . $humidity['sensor_descr'] . "</a>";
|
||||
|
||||
$humidity['sensor_descr'] = truncate($humidity['sensor_descr'], 25, '');
|
||||
echo("<tr bgcolor='$row_colour'><td class=tablehead><strong>$humidity_link_a</strong></td><td width=80 align=right class=tablehead>$humidity_link_b<td width=35 align=right class=tablehead>$humidity_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>");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$datas = array('Processors','Memory','Storage','Temperatures', 'Fanspeeds', 'Voltages', 'Frequencies', 'Current');
|
||||
$datas = array('Processors','Memory','Storage','Temperatures', 'Humidity', 'Fanspeeds', 'Voltages', 'Frequencies', 'Current');
|
||||
|
||||
if(!$_GET['opta']) { $_GET['opta'] = "processors"; }
|
||||
if(!$_GET['optb']) { $_GET['optb'] = "nographs"; }
|
||||
@@ -57,6 +57,7 @@ switch ($_GET['opta'])
|
||||
case 'memory':
|
||||
case 'storage':
|
||||
case 'temperatures':
|
||||
case 'humidity':
|
||||
case 'voltages':
|
||||
case 'fanspeeds':
|
||||
case 'frequencies':
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
if($_SESSION['userlevel'] >= '5') {
|
||||
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='humidity' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_index, S.sensor_descr";
|
||||
} else {
|
||||
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='humidity' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_index, S.sensor_descr";
|
||||
}
|
||||
|
||||
$query = mysql_query($sql);
|
||||
|
||||
echo('<table cellspacing="0" cellpadding="6" width="100%">');
|
||||
|
||||
echo('<tr class=tablehead>
|
||||
<th width="280">Device</th>
|
||||
<th width="280">Sensor</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th width="100">Current</th>
|
||||
<th width="100">Alert</th>
|
||||
<th>Notes</th>
|
||||
</tr>');
|
||||
|
||||
$row = 1;
|
||||
|
||||
while($humidity = mysql_fetch_array($query))
|
||||
{
|
||||
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
$weekly_humidity = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$week&to=$now&width=500&height=150";
|
||||
$humidity_popup = "<a onmouseover=\"return overlib('<img src=\'$weekly_humidity\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
" . $humidity['sensor_descr'] . "</a>";
|
||||
|
||||
$humidity['sensor_current'] = round($humidity['sensor_current'],1);
|
||||
|
||||
$humidity_perc = $humidity['sensor_current'] / $humidity['sensor_limit'] * 100;
|
||||
$humidity_colour = percent_colour($humidity_perc);
|
||||
|
||||
if($humidity['sensor_current'] >= $humidity['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
|
||||
|
||||
$humidity_day = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$day&to=$now&width=300&height=100";
|
||||
$humidity_week = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$week&to=$now&width=300&height=100";
|
||||
$humidity_month = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$month&to=$now&width=300&height=100";
|
||||
$humidity_year = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$year&to=$now&width=300&height=100";
|
||||
|
||||
$humidity_minigraph = "<img src='graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$day&to=$now&width=100&height=20'";
|
||||
$humidity_minigraph .= " onmouseover=\"return overlib('<div class=list-large>".$humidity['hostname']." - ".$humidity['sensor_descr'];
|
||||
$humidity_minigraph .= "</div><div style=\'width: 750px\'><img src=\'$humidity_day\'><img src=\'$humidity_week\'><img src=\'$humidity_month\'><img src=\'$humidity_year\'></div>', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >";
|
||||
|
||||
echo("<tr bgcolor=$row_colour>
|
||||
<td class=list-bold>" . generatedevicelink($humidity) . "</td>
|
||||
<td>$humidity_popup</td>
|
||||
<td>$humidity_minigraph</td>
|
||||
<td width=100>$alert</td>
|
||||
<td style='color: $humidity_colour; text-align: center; font-weight: bold;'>" . $humidity['sensor_current'] . " %</td>
|
||||
<td style='text-align: center'>" . $humidity['sensor_limit'] . " %</td>
|
||||
<td>" . (isset($humidity['sensor_notes']) ? $humidity['sensor_notes'] : '') . "</td>
|
||||
</tr>\n");
|
||||
|
||||
if($_GET['optb'] == "graphs") { ## If graphs
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=7>");
|
||||
|
||||
$daily_graph = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$day&to=$now&width=211&height=100";
|
||||
$daily_url = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$day&to=$now&width=400&height=150";
|
||||
|
||||
$weekly_graph = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$week&to=$now&width=211&height=100";
|
||||
$weekly_url = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$week&to=$now&width=400&height=150";
|
||||
|
||||
$monthly_graph = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$month&to=$now&width=211&height=100";
|
||||
$monthly_url = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$month&to=$now&width=400&height=150";
|
||||
|
||||
$yearly_graph = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&from=$year&to=$now&width=211&height=100";
|
||||
$yearly_url = "graph.php?id=" . $humidity['sensor_id'] . "&type=humidity&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>");
|
||||
|
||||
} # endif graphs
|
||||
|
||||
|
||||
|
||||
$row++;
|
||||
|
||||
}
|
||||
|
||||
echo("</table>");
|
||||
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user