mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00: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:
51
html/includes/graphs/device_humidity.inc.php
Normal file
51
html/includes/graphs/device_humidity.inc.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
include("common.inc.php");
|
||||
$device = device_by_id_cache($id);
|
||||
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='humidity' AND device_id = '$id' ORDER BY sensor_index");
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
while($humidity = 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;
|
||||
}
|
||||
|
||||
$humidity['sensor_descr_fixed'] = substr(str_pad($humidity['sensor_descr'], 22),0,22);
|
||||
$humidityrrd = $config['rrd_dir'] . "/".$device['hostname']."/".safename("humidity-" . $humidity['sensor_descr'] . ".rrd");
|
||||
$rrd_options .= " DEF:humidity" . $humidity['sensor_id'] . "=$humidityrrd:humidity:AVERAGE ";
|
||||
$rrd_options .= " LINE1:humidity" . $humidity['sensor_id'] . "#" . $colour . ":'" . str_replace(':','\:',str_replace('\*','*',quotemeta($humidity['sensor_descr_fixed']))) . "' ";
|
||||
$rrd_options .= " GPRINT:humidity" . $humidity['sensor_id'] . ":LAST:%3.0lf%% ";
|
||||
$rrd_options .= " GPRINT:humidity" . $humidity['sensor_id'] . ":MIN:%3.0lf%% ";
|
||||
$rrd_options .= " GPRINT:humidity" . $humidity['sensor_id'] . ":MAX:%3.0lf%%\\\l ";
|
||||
$iter++;
|
||||
}
|
||||
|
||||
|
||||
?>
|
37
html/includes/graphs/humidity.inc.php
Normal file
37
html/includes/graphs/humidity.inc.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
$scale_min = "25";
|
||||
$scale_max = "40";
|
||||
|
||||
include("common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$humidity = mysql_fetch_array(mysql_query("SELECT * FROM sensors WHERE sensor_class='humidity' AND sensor_id = '".mres($_GET['id'])."'"));
|
||||
|
||||
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $humidity['device_id'] . "'"),0);
|
||||
|
||||
$humidity['sensor_descr_fixed'] = substr(str_pad($humidity['sensor_descr'], 28),0,28);
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("humidity-" . $humidity['sensor_descr'] . ".rrd");
|
||||
|
||||
|
||||
$rrd_options .= " DEF:humidity=$rrd_filename:humidity:AVERAGE";
|
||||
$rrd_options .= " DEF:humidity_max=$rrd_filename:humidity:MAX";
|
||||
$rrd_options .= " DEF:humidity_min=$rrd_filename:humidity:MIN";
|
||||
$rrd_options .= " CDEF:humiditywarm=humidity_max,".$humidity['sensor_limit'].",GT,humidity,UNKN,IF";
|
||||
$rrd_options .= " CDEF:humiditycold=humidity_min,20,LT,humidity,UNKN,IF";
|
||||
$rrd_options .= " AREA:humidity_max#c5c5c5";
|
||||
$rrd_options .= " AREA:humidity_min#ffffffff";
|
||||
|
||||
|
||||
|
||||
# $rrd_options .= " AREA:humidity#bbd392";
|
||||
# $rrd_options .= " AREA:humiditywarm#FFCCCC";
|
||||
# $rrd_options .= " AREA:humiditycold#CCCCFF";
|
||||
$rrd_options .= " LINE1:humidity#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($humidity['sensor_descr_fixed'])))."'"; # Ugly hack :(
|
||||
$rrd_options .= " LINE1:humiditywarm#660000";
|
||||
$rrd_options .= " GPRINT:humidity:LAST:%3.0lf%%";
|
||||
$rrd_options .= " GPRINT:humidity:MAX:%3.0lf%%\\\\l";
|
||||
|
||||
?>
|
@@ -7,7 +7,6 @@ include("common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$sql = mysql_query("SELECT * FROM temperature where temp_id = '$temp'");
|
||||
$temperature = mysql_fetch_array(mysql_query("SELECT * FROM temperature where temp_id = '".mres($_GET['id'])."'"));
|
||||
|
||||
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $temperature['device_id'] . "'"),0);
|
||||
|
Reference in New Issue
Block a user