Fixed problems with oracle in snmp console. Tiquet: #2943
(cherry picked from commit b4ebdb1c8e
)
This commit is contained in:
parent
601ff4e4c8
commit
ca67569afa
|
@ -175,26 +175,31 @@ foreach ($all_traps as $trap) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$rows = db_get_all_rows_filter('tagente',
|
switch ($config["dbtype"]) {
|
||||||
|
case "mysql":
|
||||||
|
case "postgresql":
|
||||||
|
$rows = db_get_all_rows_filter('tagente',
|
||||||
array('id_grupo' => array_keys($user_groups)),
|
array('id_grupo' => array_keys($user_groups)),
|
||||||
array('id_agente'));
|
array('id_agente'));
|
||||||
$id_agents = array();
|
$id_agents = array();
|
||||||
foreach ($rows as $row)
|
foreach ($rows as $row)
|
||||||
$id_agents[] = $row['id_agente'];
|
$id_agents[] = $row['id_agente'];
|
||||||
$address_by_user_groups = agents_get_addresses($id_agents);
|
$address_by_user_groups = agents_get_addresses($id_agents);
|
||||||
foreach ($address_by_user_groups as $i => $a)
|
foreach ($address_by_user_groups as $i => $a)
|
||||||
$address_by_user_groups[$i] = '"' . $a . '"';
|
$address_by_user_groups[$i] = '"' . $a . '"';
|
||||||
|
|
||||||
$rows = db_get_all_rows_filter('tagente',
|
$rows = db_get_all_rows_filter('tagente',
|
||||||
array(),
|
array(),
|
||||||
array('id_agente'));
|
array('id_agente'));
|
||||||
$id_agents = array();
|
$id_agents = array();
|
||||||
foreach ($rows as $row)
|
foreach ($rows as $row)
|
||||||
$id_agents[] = $row['id_agente'];
|
$id_agents[] = $row['id_agente'];
|
||||||
$all_address_agents = agents_get_addresses($id_agents);
|
$all_address_agents = agents_get_addresses($id_agents);
|
||||||
foreach ($all_address_agents as $i => $a)
|
foreach ($all_address_agents as $i => $a)
|
||||||
$all_address_agents[$i] = '"' . $a . '"';
|
$all_address_agents[$i] = '"' . $a . '"';
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Make query to extract traps of DB.
|
//Make query to extract traps of DB.
|
||||||
|
@ -233,7 +238,11 @@ switch ($config["dbtype"]) {
|
||||||
ORDER BY timestamp DESC";
|
ORDER BY timestamp DESC";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$sql_all = "SELECT *
|
|
||||||
|
switch ($config["dbtype"]) {
|
||||||
|
case "mysql":
|
||||||
|
case "postgresql":
|
||||||
|
$sql_all = "SELECT *
|
||||||
FROM ttrap
|
FROM ttrap
|
||||||
WHERE (
|
WHERE (
|
||||||
source IN (" . implode(",", $address_by_user_groups) . ") OR
|
source IN (" . implode(",", $address_by_user_groups) . ") OR
|
||||||
|
@ -242,7 +251,7 @@ $sql_all = "SELECT *
|
||||||
)
|
)
|
||||||
%s
|
%s
|
||||||
ORDER BY timestamp DESC";
|
ORDER BY timestamp DESC";
|
||||||
$sql_count = "SELECT COUNT(id_trap)
|
$sql_count = "SELECT COUNT(id_trap)
|
||||||
FROM ttrap
|
FROM ttrap
|
||||||
WHERE (
|
WHERE (
|
||||||
source IN (" . implode(",", $address_by_user_groups) . ") OR
|
source IN (" . implode(",", $address_by_user_groups) . ") OR
|
||||||
|
@ -250,6 +259,26 @@ $sql_count = "SELECT COUNT(id_trap)
|
||||||
source NOT IN (" . implode(",", $all_address_agents) . ")
|
source NOT IN (" . implode(",", $all_address_agents) . ")
|
||||||
)
|
)
|
||||||
%s";
|
%s";
|
||||||
|
break;
|
||||||
|
case "oracle":
|
||||||
|
$sql_all = "SELECT *
|
||||||
|
FROM ttrap
|
||||||
|
WHERE (source IN (
|
||||||
|
SELECT direccion FROM tagente
|
||||||
|
WHERE id_grupo IN ($str_user_groups)
|
||||||
|
) OR source='' OR source NOT IN (SELECT direccion FROM tagente))
|
||||||
|
%s
|
||||||
|
ORDER BY timestamp DESC";
|
||||||
|
$sql_count = "SELECT COUNT(id_trap)
|
||||||
|
FROM ttrap
|
||||||
|
WHERE (
|
||||||
|
source IN (
|
||||||
|
SELECT direccion FROM tagente
|
||||||
|
WHERE id_grupo IN ($str_user_groups)
|
||||||
|
) OR source='' OR source NOT IN (SELECT direccion FROM tagente))
|
||||||
|
%s";
|
||||||
|
break;
|
||||||
|
}
|
||||||
//$whereSubquery = 'WHERE 1=1';
|
//$whereSubquery = 'WHERE 1=1';
|
||||||
$whereSubquery = '';
|
$whereSubquery = '';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue