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

* include/functions_modules.php,
	include/functions_agents.php,
	operation/tree.php: Improved performance for
	tree view module tab.

	MERGED FROM 4.0.2



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6488 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
darode 2012-06-11 15:08:25 +00:00
parent fbb0318785
commit 27028ba81a
4 changed files with 37 additions and 13 deletions

View File

@ -1,3 +1,12 @@
2012-06-11 Dario Rodriguez <dario.rodriguez@artica.es>
* include/functions_modules.php,
include/functions_agents.php,
operation/tree.php: Improved performance for
tree view module tab.
MERGED FROM 4.0.2
2012-06-11 Dario Rodriguez <dario.rodriguez@artica.es>
* include/functions_modules.php,

View File

@ -1881,7 +1881,7 @@ function agents_monitor_unknown ($id_agent, $filter="") {
if ($filter) {
$filter = " AND ".$filter;
}
return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) 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 = $id_agent".$filter);
}

View File

@ -1268,8 +1268,7 @@ function modules_agents_ok ($module_name) {
//Then we count the agents of the group selected to know how many agents are in OK status
//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 = '$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_modulo.nombre = '$module_name' GROUP BY tagente.id_agente HAVING max_estado = 0) AS S1");
}
@ -1285,7 +1284,7 @@ function modules_agents_critical ($module_name) {
//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 = '$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_modulo.nombre = '$module_name'");
}
@ -1302,7 +1301,7 @@ function modules_agents_warning ($module_name) {
//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 = '$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_modulo.nombre = '$module_name' GROUP BY tagente.id_agente HAVING min_estado = 2) AS S1");
}

View File

@ -288,14 +288,16 @@ if (is_ajax ())
//example:
// "Load_articapandora_32_pandoraartica_Average"
//result -> "Load Average"
$name = str_replace(array('_articapandora_'.ord(' ').'_pandoraartica_', '_articapandora_'.ord('#').'_pandoraartica_'),array(' ','#'),$id);
$name = str_replace(array('_articapandora_'.ord(' ').'_pandoraartica_', '_articapandora_'.ord('#').'_pandoraartica_','_articapandora_'.ord('/').'_pandoraartica_'),array(' ','#','/'),$id);
$name = io_safe_input($name);
$sql = sprintf('SELECT *
FROM tagente
WHERE id_agente IN (
SELECT id_agente
FROM tagente_modulo
WHERE nombre COLLATE utf8_general_ci LIKE \'%s\'
WHERE nombre = \'%s\'
)
AND (%s id_grupo IN (%s))', $name, $extra_sql, $groups_sql);
break;
@ -366,11 +368,26 @@ if (is_ajax ())
case 'module':
switch ($config["dbtype"]) {
case "mysql":
$agent_info = reporting_get_agent_module_info ($row["id_agente"], ' nombre COLLATE utf8_general_ci LIKE "' . $name . '"');
$agent_info["monitor_alertsfired"] = agents_get_alerts_fired ($row["id_agente"], ' tagente_modulo.nombre COLLATE utf8_general_ci = "' . $name . '"');
$agent_info["monitor_critical"] = agents_monitor_critical($row["id_agente"], ' tagente_modulo.nombre COLLATE utf8_general_ci = "' . $name . '"');
$agent_info["monitor_warning"] = agents_monitor_warning ($row["id_agente"], ' tagente_modulo.nombre COLLATE utf8_general_ci = "' . $name . '"');
$agent_info["monitor_unknown"] = agents_monitor_unknown ($row["id_agente"], ' tagente_modulo.nombre COLLATE utf8_general_ci = "' . $name . '"');
$agent_info["monitor_normal"] = agents_monitor_ok ($row["id_agente"], ' tagente_modulo.nombre COLLATE utf8_general_ci = "' . $name . '"');
$agent_info["alert_img"] = agents_tree_view_alert_img ($agent_info["monitor_alertsfired"]);
$agent_info["status_img"] = agetns_tree_view_status_img ($agent_info["monitor_critical"],
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
//Count all modules
$agent_info["modules"] = $agent_info["monitor_critical"] + $agent_info["monitor_warning"] + $agent_info["monitor_unknown"] + $agent_info["monitor_normal"];
break;
case "postgresql":
case "oracle":
$agent_info = reporting_get_agent_module_info ($row["id_agente"], ' nombre COLLATE utf8_general_ci LIKE \'' . $name . '\'');
//TODO REVIEW ORACLE AND POSTGRESQL
$agent_info = reporting_get_agent_module_info ($row["id_agente"], ' tagente_modulo.nombre COLLATE utf8_general_ci = \'' . $name . '\'');
break;
}
break;
@ -504,7 +521,7 @@ if (is_ajax ())
$sql = 'SELECT *
FROM tagente_modulo AS t1
INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo
WHERE t1.id_agente = ' . $id . ' AND nombre COLLATE utf8_general_ciLIKE \'' . io_safe_input($name) . '\'';
WHERE t1.id_agente = ' . $id . ' AND nombre COLLATE utf8_general_ci LIKE \'' . io_safe_input($name) . '\'';
break;
}
break;
@ -821,8 +838,7 @@ function printTree_($type) {
$num_unknown = policies_agents_unknown($id);
break;
case 'module':
$id = str_replace(array(' ','#'), array('_articapandora_'.ord(' ').'_pandoraartica_', '_articapandora_'.ord('#').'_pandoraartica_'),io_safe_output($item['nombre']));
$id = str_replace ("/", "_", $id);
$id = str_replace(array(' ','#','/'), array('_articapandora_'.ord(' ').'_pandoraartica_', '_articapandora_'.ord('#').'_pandoraartica_', '_articapandora_'.ord('/').'_pandoraartica_'),io_safe_output($item['nombre']));
$name = io_safe_output($item['nombre']);
$module_name = $item['nombre'];
$num_ok = modules_agents_ok($module_name);