more fixes for new sensor setup. more to come no doubt. also started making graphs which can 'widen'

git-svn-id: http://www.observium.org/svn/observer/trunk@1534 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-07-29 21:45:25 +00:00
parent 7b2fc2dbe1
commit 21dbee7c20
8 changed files with 76 additions and 63 deletions
@@ -3,11 +3,12 @@
include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_options .= " -l 0 -E ";
if($_GET['width'] > "300") { $descr_len = "40"; } else { $descr_len = "22"; }
$rrd_options .= " -l 0 -E ";
$iter = "1";
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='temperature' AND device_id = '$id' ORDER BY sensor_index");
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
$rrd_options .= " COMMENT:'".str_pad('',$descr_len)." Cur Min Max\\n'";
while($temperature = mysql_fetch_array($sql))
{
switch ($iter)
@@ -37,7 +38,7 @@ while($temperature = mysql_fetch_array($sql))
break;
}
$temperature['sensor_descr_fixed'] = substr(str_pad($temperature['sensor_descr'], 22),0,22);
$temperature['sensor_descr_fixed'] = substr(str_pad($temperature['sensor_descr'], $descr_len),0,$descr_len);
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . safename($temperature['sensor_type']."-".$temperature['sensor_index']) . ".rrd";
$rrd_options .= " DEF:temp" . $temperature['sensor_id'] . "=$rrd_file:temp:AVERAGE ";
$rrd_options .= " LINE1:temp" . $temperature['sensor_id'] . "#" . $colour . ":'" . str_replace(':','\:',str_replace('\*','*',$temperature['sensor_descr_fixed'])) . "'";
+14 -11
View File
@@ -5,10 +5,12 @@ $device = device_by_id_cache($id);
$rrd_options .= " -l 0 -E ";
if($_GET['width'] > "300") { $descr_len = "38"; } else { $descr_len = "18"; }
$rrd_options .= " COMMENT:'".str_pad('',$descr_len)." Cur Min Max\\n'";
$iter = "1";
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='voltage' AND device_id = '$id'");
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
while($voltage = mysql_fetch_array($sql))
while($sensor = mysql_fetch_array($sql))
{
switch ($iter)
{
@@ -37,17 +39,18 @@ while($voltage = mysql_fetch_array($sql))
break;
}
$hostname = gethostbyid($voltage['device_id']);
$descr = substr(str_pad($voltage['sensor_descr'], 15),0,15);
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("volt-" . $voltage['sensor_descr'] . ".rrd");
$volt_id = $voltage['sensor_id'];
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], $descr_len),0,$descr_len);
$sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed']));
$rrd_options .= " DEF:volt$volt_id=$rrd_filename:volt:AVERAGE";
$rrd_options .= " LINE1:volt$volt_id#".$colour.":'" . $descr . "'";
$rrd_options .= " GPRINT:volt$volt_id:AVERAGE:%5.2lfV";
$rrd_options .= " GPRINT:volt$volt_id:MIN:%5.2lfV";
$rrd_options .= " GPRINT:volt$volt_id:MAX:%5.2lfV\\\\l";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/volt-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
$sensor_id = $sensor['sensor_id'];
$rrd_options .= " DEF:s$sensor_id=$rrd_filename:volt:AVERAGE";
$rrd_options .= " LINE1:s$sensor_id#".$colour.":'" . $sensor['sensor_descr_fixed'] . "'";
$rrd_options .= " GPRINT:s$sensor_id:AVERAGE:%5.2lfV";
$rrd_options .= " GPRINT:s$sensor_id:MIN:%5.2lfV";
$rrd_options .= " GPRINT:s$sensor_id:MAX:%5.2lfV\\\\l";
$iter++;
}
@@ -11,6 +11,7 @@ include("includes/graphs/common.inc.php");
$device = device_by_id_cache($sensor['device_id']);
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 22),0,22);
$sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed']));
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
@@ -29,7 +30,7 @@ include("includes/graphs/common.inc.php");
# $rrd_options .= " AREA:tempwarm#FFCCCC";
# $rrd_options .= " AREA:tempcold#CCCCFF";
# $rrd_options .= " LINE1:temp#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($sensor['sensor_descr_fixed'])))."'"; # Ugly hack :(
$rrd_options .= " LINE1:temp#cc0000:'" . str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed']))."'"; # Ugly hack :(
$rrd_options .= " LINE1:temp#cc0000:'" . $sensor['sensor_descr_fixed']."'";
$rrd_options .= " LINE1:tempwarm#660000";
$rrd_options .= " GPRINT:temp:LAST:%4.1lfC";
$rrd_options .= " GPRINT:temp:MIN:%4.1lfC";
+13 -16
View File
@@ -6,26 +6,23 @@ include("includes/graphs/common.inc.php");
$rrd_options .= " -A ";
$rrd_options .= " COMMENT:' Last Max\\n'";
$rrd_options .= " COMMENT:' Last Max\\n'";
$voltage = mysql_fetch_array(mysql_query("SELECT * FROM sensors WHERE sensor_class='voltage' AND sensor_id = '".mres($_GET['id'])."'"));
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 22),0,22);
$sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed']));
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $voltage['device_id'] . "'"),0);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/volt-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
$voltage['sensor_descr_fixed'] = substr(str_pad($voltage['sensor_descr'], 22),0,22);
$rrd_options .= " DEF:volt=$rrd_filename:volt:AVERAGE";
$rrd_options .= " DEF:volt_max=$rrd_filename:volt:MAX";
$rrd_options .= " DEF:volt_min=$rrd_filename:volt:MIN";
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("volt-" . $voltage['sensor_descr'] . ".rrd");
$rrd_options .= " AREA:volt_max#c5c5c5";
$rrd_options .= " AREA:volt_min#ffffffff";
$rrd_options .= " DEF:volt=$rrd_filename:volt:AVERAGE";
$rrd_options .= " DEF:volt_max=$rrd_filename:volt:MAX";
$rrd_options .= " DEF:volt_min=$rrd_filename:volt:MIN";
$rrd_options .= " AREA:volt_max#c5c5c5";
$rrd_options .= " AREA:volt_min#ffffffff";
#$rrd_options .= " AREA:volt#FFFF99";
$rrd_options .= " LINE1.5:volt#cc0000:'" . $voltage['sensor_descr_fixed']."'";
$rrd_options .= " GPRINT:volt:LAST:%3.2lfV";
$rrd_options .= " GPRINT:volt:MAX:%3.2lfV\\\\l";
#$rrd_options .= " AREA:volt#FFFF99";
$rrd_options .= " LINE1.5:volt#cc0000:'" . $sensor['sensor_descr_fixed']."'";
$rrd_options .= " GPRINT:volt:LAST:%3.2lfV";
$rrd_options .= " GPRINT:volt:MAX:%3.2lfV\\\\l";
?>