diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 485a33abf..0d6bafe23 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -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"); } } diff --git a/includes/discovery/toner.inc.php b/includes/discovery/toner.inc.php index 43581100c..76c149ecf 100644 --- a/includes/discovery/toner.inc.php +++ b/includes/discovery/toner.inc.php @@ -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); } } } diff --git a/includes/polling/os/unix.inc.php b/includes/polling/os/unix.inc.php index a3c4fe8ba..ccad4273f 100755 --- a/includes/polling/os/unix.inc.php +++ b/includes/polling/os/unix.inc.php @@ -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,'#'); diff --git a/includes/polling/toner.inc.php b/includes/polling/toner.inc.php index 798020022..e7c5c0748 100755 --- a/includes/polling/toner.inc.php +++ b/includes/polling/toner.inc.php @@ -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"); diff --git a/sql-schema/019.sql b/sql-schema/019.sql new file mode 100644 index 000000000..0d1622ce0 --- /dev/null +++ b/sql-schema/019.sql @@ -0,0 +1 @@ +ALTER TABLE `toner` ADD `toner_capacity_oid` VARCHAR( 64 );