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
This commit is contained in:
Tom Laermans
2010-06-17 14:26:30 +00:00
parent 2da9a05a00
commit 0bcea700cc
2 changed files with 8 additions and 6 deletions

View File

@@ -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;
}

View File

@@ -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'])
?>