From 0bcea700cc28efb50ccbfe97c71da6b0dc914ea9 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Thu, 17 Jun 2010 14:26:30 +0000 Subject: [PATCH] fix the last discovery function to use the by-reference array, toner git-svn-id: http://www.observium.org/svn/observer/trunk@1198 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/discovery/functions.inc.php | 3 ++- includes/discovery/toner.inc.php | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index dfe617f27..16a29c6db 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -332,7 +332,7 @@ function discover_current(&$valid, $device, $oid, $index, $type, $descr, $precis return $return; } -function discover_toner($device, $oid, $index, $type, $descr, $capacity = NULL, $current = NULL) +function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity = NULL, $current = NULL) { global $config, $debug; @@ -359,6 +359,7 @@ function discover_toner($device, $oid, $index, $type, $descr, $capacity = NULL, } } + $valid[$type][$index] = 1; return $return; } diff --git a/includes/discovery/toner.inc.php b/includes/discovery/toner.inc.php index 5336b5cd3..1e9bb3092 100644 --- a/includes/discovery/toner.inc.php +++ b/includes/discovery/toner.inc.php @@ -9,6 +9,8 @@ $community = $device['community']; $snmpver = $device['snmpver']; $port = $device['port']; +$valid_toner = array(); + echo("Toner : "); if ($device['os'] == "dell-laser") @@ -34,8 +36,7 @@ if ($device['os'] == "dell-laser") $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; + echo discover_toner($valid_toner,$device, $toner_oid, $index, $type, $descr, $capacity, $current); } } } @@ -43,7 +44,7 @@ if ($device['os'] == "dell-laser") ## Delete removed toners -if($debug) { echo("\n Checking ... \n"); print_r($toner_exists); } +if($debug) { echo("\n Checking ... \n"); print_r($valid_toner); } $sql = "SELECT * FROM toner WHERE device_id = '".$device['device_id']."'"; if ($query = mysql_query($sql)) @@ -52,7 +53,7 @@ if ($query = mysql_query($sql)) { $toner_index = $test_toner['toner_index']; $toner_type = $test_toner['toner_type']; - if(!$toner_exists[$toner_type][$toner_index]) { + if(!$valid_toner[$toner_type][$toner_index]) { echo("-"); mysql_query("DELETE FROM `toner` WHERE toner_id = '" . $test_toner['toner_id'] . "'"); } @@ -61,7 +62,7 @@ if ($query = mysql_query($sql)) -unset($toner_exists); echo("\n"); +unset($valid_toner); echo("\n"); } # if ($config['enable_printers']) ?>