make sure capacity oid actually ends up in database for already existing toner

git-svn-id: http://www.observium.org/svn/observer/trunk@3140 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2012-05-06 20:07:03 +00:00
parent e33c1f0de1
commit baa4f44c4e
3 changed files with 5 additions and 8 deletions

View File

@@ -38,9 +38,6 @@ $config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth
$config['nets'][] = "172.22.0.0/16";
$config['nets'][] = "192.168.0.0/24";
### Use the new Unix Agent (ALPHA)
$config['poller_modules']['unix-agent'] = 0;
include("includes/static-config.php");
?>

View File

@@ -465,13 +465,13 @@ function discover_mempool(&$valid, $device, $index, $type, $descr, $precision =
}
}
function discover_toner(&$valid, $device, $oid, $capacity_oid, $index, $type, $descr, $capacity = NULL, $current = NULL)
function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity_oid = NULL, $capacity = NULL, $current = NULL)
{
global $config, $debug;
if ($debug) { echo("$oid, $index, $type, $descr, $capacity\n"); }
if ($debug) { echo("$oid, $index, $type, $descr, $capacity, $capacity_oid\n"); }
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')
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' AND `toner_capacity_oid` = '$capacity_oid'"),0) == '0')
{
$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')";
@@ -482,7 +482,7 @@ function discover_toner(&$valid, $device, $oid, $capacity_oid, $index, $type, $d
else
{
$toner_entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `toner` WHERE device_id = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index'"));
if ($oid == $toner_entry['toner_oid'] && $descr == $toner_entry['toner_descr'] && $capacity == $toner_entry['toner_capacity'])
if ($oid == $toner_entry['toner_oid'] && $descr == $toner_entry['toner_descr'] && $capacity == $toner_entry['toner_capacity'] && $capacity_oid == $toner_entry['toner_capacity_oid'])
{
echo(".");
}

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, $capacity_oid, $index, $type, $descr, $capacity, $current);
discover_toner($valid_toner,$device, $toner_oid, $index, $type, $descr, $capacity_oid, $capacity, $current);
}
}
}