toner graphing

git-svn-id: http://www.observium.org/svn/observer/trunk@1016 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-03-12 18:13:30 +00:00
parent 116f846470
commit 7087782cdb
5 changed files with 66 additions and 2 deletions

View File

@@ -0,0 +1,55 @@
<?php
include("common.inc.php");
$rrd_options .= " -l 0 -E ";
$iter = "1";
$sql = mysql_query("SELECT * FROM toner where device_id = '$device_id'");
$rrd_options .= " COMMENT:'RPM Cur Min Max\\n'";
while($toner = 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;
}
$hostname = gethostbyid($toner['device_id']);
$descr = substr(str_pad($toner['toner_descr'], 17),0,17);
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("toner-" . $toner['toner_descr'] . ".rrd");
$toner_id = $toner['toner_id'];
$rrd_options .= " DEF:toner$toner_id=$rrd_filename:toner:AVERAGE";
$rrd_options .= " LINE1: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";
$iter++;
}
?>

View File

@@ -160,7 +160,7 @@ if(mysql_result(mysql_query("select count(service_id) from services WHERE device
if(@mysql_result(mysql_query("select count(toner_id) from toner WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
echo('<li class="' . $select['toner'] . '">
<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/toner/">
<img src="images/16/color_wheel.png" align="absmiddle" border="0" /> Toner
<img src="images/16/palette.png" align="absmiddle" border="0" /> Toner
</a>
</li>');
}

View File

@@ -0,0 +1,8 @@
<?php
$graph_title = "Toner";
$graph_type = "device_toner";
include ("includes/print-device-graph.php");
?>

View File

@@ -32,6 +32,7 @@ if ($device['os'] == "dell-laser")
$descr = str_replace('"','',snmp_get($device, $descr_oid, "-Oqv"));
$current = snmp_get($device, $toner_oid, "-Oqv");
$capacity = snmp_get($device, $capacity_oid, "-Oqv");
$current = $current / $capacity * 100;
$type = "dell-laser";
echo discover_toner($device, $toner_oid, $index, $type, $descr, $capacity, $current);
$toner_exists[$type][$index] = 1;

View File

@@ -1,6 +1,6 @@
<?php
if ($config['show_printers'])
if ($config['enable_printers'])
{
$query = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'";
$toner_data = mysql_query($query);