unified sensors grapher

git-svn-id: http://www.observium.org/svn/observer/trunk@2172 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-04-26 15:59:10 +00:00
parent 2a276a3d07
commit 10b150c032
2 changed files with 54 additions and 2 deletions
@@ -0,0 +1,52 @@
<?php
include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
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='".$class."' AND device_id = '$id' ORDER BY sensor_index");
$rrd_options .= " COMMENT:'".str_pad($unit_long,$descr_len)." Cur Min Max\\n'";
while ($sensor = mysql_fetch_assoc($sql))
{
# FIXME generic colour function
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;
}
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], $descr_len),0,$descr_len);
$rrd_file = get_sensor_rrd($device, $sensor);
$rrd_options .= " DEF:sensor" . $sensor['sensor_id'] . "=$rrd_file:sensor:AVERAGE ";
$rrd_options .= " LINE1:sensor" . $sensor['sensor_id'] . "#" . $colour . ":'" . str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed'])) . "'";
$rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":LAST:%4.1lf".$unit." ";
$rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":MIN:%4.1lf".$unit." ";
$rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":MAX:%4.1lf".$unit."\\\l ";
$iter++;
}
?>
+2 -2
View File
@@ -153,9 +153,9 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
if ($links > 10) ### Unflatten if there are more than 10 links. beyond that it gets messy
{
$maptool = 'unflatten -f -l 5 |dot';
$maptool = 'unflatten -f -l 5 | twopi';
} else {
$maptool = 'dot';
$maptool = 'twopi';
}
if ($where == '') { $maptool = 'neato -Gpack'; }