repoll toner capacity

git-svn-id: http://www.observium.org/svn/observer/trunk@3138 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2012-05-06 19:56:06 +00:00
parent ff6a049324
commit 8df5bb8f8b
5 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -465,7 +465,7 @@ function discover_mempool(&$valid, $device, $index, $type, $descr, $precision =
}
}
function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity = NULL, $current = NULL)
function discover_toner(&$valid, $device, $oid, $capacity_oid, $index, $type, $descr, $capacity = NULL, $current = NULL)
{
global $config, $debug;
@@ -473,8 +473,8 @@ function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity
if (mysql_result(mysql_query("SELECT count(toner_id) FROM `toner` WHERE device_id = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index'"),0) == '0')
{
$query = "INSERT INTO toner (`device_id`, `toner_oid`, `toner_index`, `toner_type`, `toner_descr`, `toner_capacity`, `toner_current`) ";
$query .= " VALUES ('".$device['device_id']."', '$oid', '$index', '$type', '$descr', '$capacity', '$current')";
$query = "INSERT INTO toner (`device_id`, `toner_oid`, `toner_capacity_oid`, `toner_index`, `toner_type`, `toner_descr`, `toner_capacity`, `toner_current`) ";
$query .= " VALUES ('".$device['device_id']."', '$oid', '$capacity_oid', '$index', '$type', '$descr', '$capacity', '$current')";
mysql_query($query);
echo("+");
log_event("Toner added: type ".mres($type)." index ".mres($index)." descr ". mres($descr), $device, 'toner', mysql_insert_id());
@@ -488,7 +488,7 @@ function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity
}
else
{
mysql_query("UPDATE toner SET `toner_descr` = '$descr', `toner_oid` = '$oid', `toner_capacity` = '$capacity' WHERE `device_id` = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index' ");
mysql_query("UPDATE toner SET `toner_descr` = '$descr', `toner_oid` = '$oid', `toner_capacity_oid` = '$capacity_oid', `toner_capacity` = '$capacity' WHERE `device_id` = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index' ");
echo("U");
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ if ($config['enable_printers'])
$current = $current / $capacity * 100;
$type = "jetdirect";
if (isHexString($descr)) { $descr = snmp_hexstring($descr); }
discover_toner($valid_toner,$device, $toner_oid, $index, $type, $descr, $capacity, $current);
discover_toner($valid_toner,$device, $toner_oid, $capacity_oid, $index, $type, $descr, $capacity, $current);
}
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ elseif ($device['os'] == "qnap")
}
elseif ($device['os'] == "dsm")
{
# FIXME only the build, not the actual version number, so won't use this.. yet?
# This only gets us the build, not the actual version number, so won't use this.. yet.
# list(,,,$version,) = explode(" ",$poll_device['sysDescr'],5);
# $version = "Build " . trim($version,'#');
+1 -2
View File
@@ -8,9 +8,8 @@ if ($config['enable_printers'])
{
echo("Checking toner " . $toner['toner_descr'] . "... ");
$toner['toner_capacity'] = snmp_get($device, $toner['toner_capacity_oid'], "-OUqnv");
$tonerperc = round(snmp_get($device, $toner['toner_oid'], "-OUqnv") / $toner['toner_capacity'] * 100);
# FIXME also repoll capacity, or tonerperc can be incorrect; then line below can go too
if ($tonerperc > 100) { $tonerperc = 100; } # ^
$old_tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_descr'] . ".rrd");
$tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_index'] . ".rrd");
+1
View File
@@ -0,0 +1 @@
ALTER TABLE `toner` ADD `toner_capacity_oid` VARCHAR( 64 );