genericify sensors graphs

git-svn-id: http://www.observium.org/svn/observer/trunk@2171 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-04-26 15:46:51 +00:00
parent f6a4352522
commit 2a276a3d07
6 changed files with 30 additions and 303 deletions
+5 -52
View File
@@ -1,56 +1,9 @@
<?php
include("includes/graphs/common.inc.php");
$class = "fanspeed";
$unit = "";
$unit_long = "RPM";
$device = device_by_id_cache($id);
include("includes/graphs/device/sensor.inc.php");
$rrd_options .= " -l 0 -E ";
$iter = "1";
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='fanspeed' AND device_id = '$id'");
$rrd_options .= " COMMENT:'RPM Cur Min Max\\n'";
# FIXME generic colour function
while ($fanspeed = mysql_fetch_assoc($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;
}
$descr = substr(str_pad($fanspeed['sensor_descr'], 17),0,17);
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("fanspeed-" . safename($fanspeed['sensor_type']."-".$fanspeed['sensor_index']) . ".rrd");
$fan_id = $fanspeed['sensor_id'];
$rrd_options .= " DEF:sensor$fan_id=$rrd_filename:sensor:AVERAGE";
$rrd_options .= " LINE1:sensor$fan_id#".$colour.":'" . $descr . "'";
$rrd_options .= " GPRINT:sensor$fan_id:AVERAGE:%5.0lf\ ";
$rrd_options .= " GPRINT:sensor$fan_id:MIN:%5.0lf\ ";
$rrd_options .= " GPRINT:sensor$fan_id:MAX:%5.0lf\\\\l";
$iter++;
}
?>
?>