log toner replacement

git-svn-id: http://www.observium.org/svn/observer/trunk@2122 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-04-21 10:37:55 +00:00
parent 2dfba84802
commit d599a82262
+10 -2
View File
@@ -9,6 +9,8 @@ if ($config['enable_printers'])
{
echo("Checking toner " . $toner['toner_descr'] . "... ");
# FIXME poll capacity maybe also here, when toner is replaced capacity can change, leading to "154% of toner"
$tonerperc = snmp_get($device, $toner['toner_oid'], "-OUqnv") / $toner['toner_capacity'] * 100;
$tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_descr'] . ".rrd");
@@ -27,9 +29,15 @@ if ($config['enable_printers'])
rrdtool_update($tonerrrd,"N:$tonerperc");
#FIXME could report for toner out... :)
#FIXME should report for toner out... :)
mysql_query("UPDATE toner SET toner_current = '$tonerperc' WHERE toner_id = '" . $toner['toner_id'] . "'");
# Log toner swap
if ($tonerperc > $toner['toner_current'])
{
log_event('Toner ' . $toner['toner_descr'] . ' was replaced (new level: ' . $tonerperc . '%)', $device, 'toner', $toner['toner_id']);
}
mysql_query("UPDATE toner SET toner_current = '$tonerperc', toner_capacity = '" . $toner['toner_capacity'] . "' WHERE toner_id = '" . $toner['toner_id'] . "'");
}
}