2012-06-08 Dario Rodriguez <dario.rodriguez@artica.es>

* include/functions_modules.php,
	include/functions_groups.php,
	include/functions_os.php,
	operation/tree.php: Fixed a problem with unknown agent
	counting.
	
	MERGED FROM 4.0.2



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6457 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
darode 2012-06-08 12:11:58 +00:00
parent 936c0b89ff
commit e6a9fb0d29
5 changed files with 30 additions and 18 deletions

View File

@ -1,3 +1,13 @@
2012-06-08 Dario Rodriguez <dario.rodriguez@artica.es>
* include/functions_modules.php,
include/functions_groups.php,
include/functions_os.php,
operation/tree.php: Fixed a problem with unknown agent
counting.
MERGED FROM 4.0.2
2012-06-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es> 2012-06-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* godmode/reporting/reporting_builder.php: Fixed update of custom * godmode/reporting/reporting_builder.php: Fixed update of custom

View File

@ -854,7 +854,7 @@ function groups_agent_unknown ($group_array) {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT( DISTINCT tagente_estado.id_agente) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 3 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_grupo IN $group_clause"); return db_get_sql ("SELECT COUNT(min_estado) FROM (SELECT MIN(tagente_estado.estado) as min_estado FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.estado != 0 AND tagente.id_grupo IN $group_clause GROUP BY tagente.id_agente HAVING min_estado = 3) AS S1");
} }

View File

@ -1252,8 +1252,7 @@ function modules_get_status($id_agent_module, $db_status, $data, &$status, &$tit
function modules_agents_unknown ($module_name) { function modules_agents_unknown ($module_name) {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT( DISTINCT tagente.id_agente) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.estado = 3 AND tagente_modulo.nombre = '$module_name'");
return db_get_sql ("SELECT COUNT( DISTINCT tagente_estado.id_agente) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 3 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo WHERE nombre LIKE '%$module_name%')");
} }
@ -1270,7 +1269,7 @@ function modules_agents_ok ($module_name) {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT(max_estado) FROM (SELECT MAX(tagente_estado.estado) as max_estado FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo WHERE nombre LIKE '%$module_name%') GROUP BY tagente.id_agente HAVING max_estado = 0) AS S1"); return db_get_sql ("SELECT COUNT(max_estado) FROM (SELECT MAX(tagente_estado.estado) as max_estado FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo WHERE nombre = '$module_name') GROUP BY tagente.id_agente HAVING max_estado = 0) AS S1");
} }
@ -1286,7 +1285,7 @@ function modules_agents_critical ($module_name) {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT( DISTINCT tagente_estado.id_agente) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 1 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo WHERE nombre LIKE '%$module_name%')"); return db_get_sql ("SELECT COUNT( DISTINCT tagente_estado.id_agente) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 1 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo WHERE nombre = '$module_name')");
} }
@ -1303,7 +1302,7 @@ function modules_agents_warning ($module_name) {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT(min_estado) FROM (SELECT MIN(tagente_estado.estado) as min_estado FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo WHERE nombre LIKE '%$module_name%') GROUP BY tagente.id_agente HAVING min_estado = 2) AS S1"); return db_get_sql ("SELECT COUNT(min_estado) FROM (SELECT MIN(tagente_estado.estado) as min_estado FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo WHERE nombre = '$module_name') GROUP BY tagente.id_agente HAVING min_estado = 2) AS S1");
} }

View File

@ -62,7 +62,7 @@ function os_agents_unknown ($id_os) {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT( DISTINCT tagente_estado.id_agente) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 3 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_os = $id_os"); return db_get_sql ("SELECT COUNT(min_estado) FROM (SELECT MIN(tagente_estado.estado) as min_estado FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.estado != 0 AND tagente.id_os = $id_os GROUP BY tagente.id_agente HAVING min_estado = 3) AS S1");
} }

View File

@ -439,8 +439,7 @@ if (is_ajax ())
//also aknolegment as second subtree/branch //also aknolegment as second subtree/branch
case 'agent_group': case 'agent_group':
case 'agent_module_group': case 'agent_module_group':
case 'agent_group':
case 'agent_os': case 'agent_os':
case 'agent_policies': case 'agent_policies':
case 'agent_module': case 'agent_module':
@ -716,9 +715,11 @@ function printTree_($type) {
} }
break; break;
case 'policies': case 'policies':
$groups_id = array_keys($avariableGroups);
$groups = implode(',',$groups_id);
if ($search_free != '') { if ($search_free != '') {
$groups_id = array_keys($avariableGroups);
$groups = implode(',',$groups_id);
$sql = "SELECT * FROM tpolicies $sql = "SELECT * FROM tpolicies
WHERE id_group IN ($groups) WHERE id_group IN ($groups)
AND id IN (SELECT id_policy FROM tpolicy_agents AND id IN (SELECT id_policy FROM tpolicy_agents
@ -726,7 +727,8 @@ function printTree_($type) {
WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%'))"; WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%'))";
$list = db_get_all_rows_sql($sql); $list = db_get_all_rows_sql($sql);
} else { } else {
$list = db_get_all_rows_filter('tpolicies', array('id_group' => array_keys($avariableGroups)));
$list = db_get_all_rows_sql("SELECT id, name FROM tpolicies WHERE id_group IN ($groups) AND id IN (SELECT DISTINCT id_policy FROM tpolicy_agents)");
if ($list !== false) if ($list !== false)
array_push($list, array('id' => 0, 'name' => 'No policy')); array_push($list, array('id' => 0, 'name' => 'No policy'));
} }
@ -742,15 +744,16 @@ function printTree_($type) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
$list = db_get_all_rows_sql('SELECT t1.nombre $list = db_get_all_rows_sql('SELECT t1.nombre
FROM tagente_modulo t1, tagente t2 FROM tagente_modulo t1, tagente t2, tagente_estado t3
WHERE t1.id_agente = t2.id_agente AND t2.id_grupo in (' . $avariableGroupsIds . ')' .$sql_search.' WHERE t1.id_agente = t2.id_agente AND t1.id_agente_modulo = t3.id_agente_modulo
GROUP BY t1.nombre ORDER BY t1.nombre ASC'); AND t3.utimestamp !=0 AND t2.id_grupo in (' . $avariableGroupsIds . ')' .$sql_search.'
GROUP BY t1.nombre ORDER BY t1.nombre');
break; break;
case "oracle": case "oracle":
$list = db_get_all_rows_sql('SELECT dbms_lob.substr(t1.nombre,4000,1) as nombre $list = db_get_all_rows_sql('SELECT dbms_lob.substr(t1.nombre,4000,1) as nombre
FROM tagente_modulo t1, tagente t2 FROM tagente_modulo t1, tagente t2, tagente_estado t3
WHERE t1.id_agente = t2.id_agente AND t2.id_grupo in (' . $avariableGroupsIds . ') WHERE t1.id_agente = t2.id_agente AND t2.id_grupo in (' . $avariableGroupsIds . ') AND t1.id_agente_modulo = t3.id_agente_modulo
GROUP BY dbms_lob.substr(t1.nombre,4000,1) ORDER BY dbms_lob.substr(t1.nombre,4000,1) ASC'); AND t3.utimestamp !=0 GROUP BY dbms_lob.substr(t1.nombre,4000,1) ORDER BY dbms_lob.substr(t1.nombre,4000,1) ASC');
break; break;
} }
break; break;