2010-03-12 17:33:58 +00:00
|
|
|
<?php
|
|
|
|
|
2010-03-12 18:13:30 +00:00
|
|
|
if ($config['enable_printers'])
|
2010-03-12 17:33:58 +00:00
|
|
|
{
|
|
|
|
$query = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'";
|
|
|
|
$toner_data = mysql_query($query);
|
2011-03-16 01:11:27 +00:00
|
|
|
|
2011-04-06 13:54:50 +00:00
|
|
|
while ($toner = mysql_fetch_assoc($toner_data))
|
2010-03-12 17:33:58 +00:00
|
|
|
{
|
|
|
|
echo("Checking toner " . $toner['toner_descr'] . "... ");
|
|
|
|
|
2011-03-28 20:29:34 +00:00
|
|
|
$tonerperc = snmp_get($device, $toner['toner_oid'], "-OUqnv") / $toner['toner_capacity'] * 100;
|
2010-03-12 17:33:58 +00:00
|
|
|
|
|
|
|
$tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_descr'] . ".rrd");
|
|
|
|
|
2011-03-16 01:11:27 +00:00
|
|
|
if (!is_file($tonerrrd))
|
2010-03-12 17:33:58 +00:00
|
|
|
{
|
2011-03-16 01:11:27 +00:00
|
|
|
rrdtool_create($tonerrrd,"--step 300 \
|
2010-03-12 18:28:18 +00:00
|
|
|
DS:toner:GAUGE:600:0:20000 \
|
2010-03-12 17:33:58 +00:00
|
|
|
RRA:AVERAGE:0.5:1:1200 \
|
|
|
|
RRA:MIN:0.5:12:2400 \
|
|
|
|
RRA:MAX:0.5:12:2400 \
|
2011-03-16 01:11:27 +00:00
|
|
|
RRA:AVERAGE:0.5:12:2400");
|
2010-03-12 17:33:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo($tonerperc . " %\n");
|
|
|
|
|
|
|
|
rrdtool_update($tonerrrd,"N:$tonerperc");
|
|
|
|
|
|
|
|
#FIXME could report for toner out... :)
|
|
|
|
|
|
|
|
mysql_query("UPDATE toner SET toner_current = '$tonerperc' WHERE toner_id = '" . $toner['toner_id'] . "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-16 01:11:27 +00:00
|
|
|
?>
|