2010-03-12 18:13:30 +00:00
|
|
|
<?php
|
|
|
|
|
2010-07-24 19:24:07 +00:00
|
|
|
include("includes/graphs/common.inc.php");
|
2010-05-02 19:47:09 +00:00
|
|
|
$device = device_by_id_cache($id);
|
2010-03-12 18:13:30 +00:00
|
|
|
|
|
|
|
$rrd_options .= " -l 0 -E ";
|
|
|
|
|
|
|
|
$iter = "1";
|
2010-03-12 18:22:51 +00:00
|
|
|
$rrd_options .= " COMMENT:'Toner level Cur Min Max\\n'";
|
2011-05-13 13:27:54 +00:00
|
|
|
foreach (dbFetchRows("SELECT * FROM toner where device_id = ?", array($id)) as $toner)
|
2010-03-12 18:13:30 +00:00
|
|
|
{
|
2011-04-06 13:54:50 +00:00
|
|
|
# FIXME generic colour function
|
2010-03-12 18:13:30 +00:00
|
|
|
switch ($iter)
|
|
|
|
{
|
|
|
|
case "1":
|
2011-03-12 08:50:47 +00:00
|
|
|
$colour= "000000";
|
|
|
|
break;
|
2010-03-12 18:13:30 +00:00
|
|
|
case "2":
|
2011-03-12 08:50:47 +00:00
|
|
|
$colour= "008C00";
|
|
|
|
break;
|
2010-03-12 18:13:30 +00:00
|
|
|
case "3":
|
2011-03-12 08:50:47 +00:00
|
|
|
$colour= "4096EE";
|
|
|
|
break;
|
2010-03-12 18:13:30 +00:00
|
|
|
case "4":
|
2011-03-12 08:50:47 +00:00
|
|
|
$colour= "73880A";
|
2010-03-12 18:13:30 +00:00
|
|
|
break;
|
|
|
|
case "5":
|
2011-03-12 08:50:47 +00:00
|
|
|
$colour= "D01F3C";
|
2010-03-12 18:13:30 +00:00
|
|
|
break;
|
|
|
|
case "6":
|
2011-03-12 08:50:47 +00:00
|
|
|
$colour= "36393D";
|
|
|
|
break;
|
|
|
|
case "7":
|
2010-03-12 18:13:30 +00:00
|
|
|
default:
|
2011-03-12 08:50:47 +00:00
|
|
|
$colour= "FF0000";
|
2010-03-12 18:13:30 +00:00
|
|
|
unset($iter);
|
|
|
|
break;
|
|
|
|
}
|
2011-03-12 08:50:47 +00:00
|
|
|
|
2010-07-18 20:36:23 +00:00
|
|
|
if (stripos($toner['toner_descr'],"cyan" ) !== false || substr($toner['toner_descr'],-1) == 'C') { $colour = "55D6D3"; }
|
|
|
|
if (stripos($toner['toner_descr'],"magenta") !== false || substr($toner['toner_descr'],-1) == 'M') { $colour = "F24AC8"; }
|
|
|
|
if (stripos($toner['toner_descr'],"yellow" ) !== false || substr($toner['toner_descr'],-1) == 'Y') { $colour = "FFF200"; }
|
|
|
|
if (stripos($toner['toner_descr'],"black" ) !== false || substr($toner['toner_descr'],-1) == 'K') { $colour = "000000"; }
|
2011-03-12 08:50:47 +00:00
|
|
|
|
2010-03-12 18:13:30 +00:00
|
|
|
$hostname = gethostbyid($toner['device_id']);
|
2011-03-12 08:50:47 +00:00
|
|
|
|
2010-06-10 13:07:57 +00:00
|
|
|
$descr = substr(str_pad($toner['toner_descr'], 16),0,16);
|
2011-05-03 20:13:15 +00:00
|
|
|
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("toner-" . $toner['toner_index'] . ".rrd");
|
2010-03-12 18:13:30 +00:00
|
|
|
$toner_id = $toner['toner_id'];
|
|
|
|
|
|
|
|
$rrd_options .= " DEF:toner$toner_id=$rrd_filename:toner:AVERAGE";
|
2010-06-10 13:07:57 +00:00
|
|
|
$rrd_options .= " LINE2:toner$toner_id#".$colour.":'" . $descr . "'";
|
|
|
|
$rrd_options .= " GPRINT:toner$toner_id:AVERAGE:'%5.0lf%%'";
|
|
|
|
$rrd_options .= " GPRINT:toner$toner_id:MIN:'%5.0lf%%'";
|
|
|
|
$rrd_options .= " GPRINT:toner$toner_id:MAX:%5.0lf%%\\\\l";
|
2010-03-12 18:13:30 +00:00
|
|
|
|
|
|
|
$iter++;
|
|
|
|
}
|
|
|
|
|
2011-05-03 20:13:15 +00:00
|
|
|
?>
|