diff --git a/pandora_console/godmode/reporting/cluster_view.php b/pandora_console/godmode/reporting/cluster_view.php index 050dea02c8..e6946eed78 100644 --- a/pandora_console/godmode/reporting/cluster_view.php +++ b/pandora_console/godmode/reporting/cluster_view.php @@ -32,7 +32,7 @@ ui_print_page_header ( __("Cluster detail").' ยป '.clusters_get_name($id_cluster $font_size = 10; $width = "100%"; -$height = "600"; +$height = "500"; $node_radius = 40; $baseurl = ui_get_full_url(false, false, false, false); @@ -74,7 +74,7 @@ echo ""; echo "
-
+
"; @@ -83,7 +83,7 @@ echo "
"; echo "
-
+
"; @@ -92,7 +92,7 @@ echo "
"; echo "
-
+
"; @@ -101,7 +101,7 @@ echo "
"; echo "
-
+
"; @@ -110,7 +110,7 @@ echo "
"; echo "
-
+
"; @@ -119,7 +119,7 @@ echo "
"; echo "
-
+
"; @@ -328,7 +328,7 @@ system ($cmd); unlink($filename_dot); -$nodes = cluster_loadfile($filename_plain, $graph); +$nodes = cluster_loadfile($filename_plain, $graph, $id_cluster); foreach ($nodes['nodes'] as $key => $node) { diff --git a/pandora_console/include/functions_clusters.php b/pandora_console/include/functions_clusters.php index e54e73c08c..5b89a44167 100644 --- a/pandora_console/include/functions_clusters.php +++ b/pandora_console/include/functions_clusters.php @@ -213,6 +213,100 @@ function cluster_get_status ($id_agente){ return $status; } +/** + * Get the worst status of all modules of a given cluster agent. + * + * @param int Id agent to check. + * @param bool Whether the call check ACLs or not + * + * @return int Worst status of an cluster agent for all of its modules. + * The value -1 is returned in case the agent has exceed its interval. + */ +function cluster_agents_get_status($id_agent = 0, $noACLs = false, $id_cluster = 0) { + global $config; + + if (!$noACLs) { + $sql_module_cluster = "SELECT am.nombre,am.id_agente_modulo, ae.datos, ae.estado FROM tagente_modulo am + INNER JOIN tagente_estado ae ON ae.id_agente_modulo = am.id_agente_modulo + WHERE nombre IN (SELECT name FROM tcluster_item WHERE id_cluster = $id_cluster) AND am.id_agente = $id_agent"; + + $modules = db_get_all_rows_sql ($sql_module_cluster); + } + + if (!isset($modules) || empty($modules) || count($modules) == 0) { + return AGENT_MODULE_STATUS_NOT_INIT; + } + + $modules_status = array(); + $modules_async = 0; + foreach ($modules as $module) { + + $modules_status[] = $module['estado']; + + $module_type = modules_get_agentmodule_type($module['id_agente_modulo']); + if (($module_type >= 21 && $module_type <= 23) || $module_type == 100) { + $modules_async++; + } + } + + // If all the modules are asynchronous or keep alive, the group cannot be unknown + if ($modules_async < count($modules)) { + $time = get_system_time (); + + switch ($config["dbtype"]) { + case "mysql": + $status = db_get_value_filter ('COUNT(*)', + 'tagente', + array ('id_agente' => (int) $id_agent, + 'UNIX_TIMESTAMP(ultimo_contacto) + intervalo * 2 > '.$time)); + break; + case "postgresql": + $status = db_get_value_filter ('COUNT(*)', + 'tagente', + array ('id_agente' => (int) $id_agent, + 'ceil(date_part(\'epoch\', ultimo_contacto)) + intervalo * 2 > '.$time)); + break; + case "oracle": + $status = db_get_value_filter ('count(*)', + 'tagente', + array ('id_agente' => (int) $id_agent, + 'ceil((to_date(ultimo_contacto, \'YYYY-MM-DD HH24:MI:SS\') - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (' . SECONDS_1DAY . ')) > ' . $time)); + break; + } + + if (! $status) + return AGENT_MODULE_STATUS_UNKNOWN; + } + + // Checking if any module has alert fired + if (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_ALERT, $modules_status))) { + return AGENT_MODULE_STATUS_CRITICAL_ALERT; + } + // Checking if any module has alert fired + elseif (is_int(array_search(AGENT_MODULE_STATUS_WARNING_ALERT, $modules_status))) { + return AGENT_MODULE_STATUS_WARNING_ALERT; + } + // Checking if any module has critical status + elseif (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_BAD, $modules_status))) { + return AGENT_MODULE_STATUS_CRITICAL_BAD; + } + // Checking if any module has critical status + elseif (is_int(array_search(AGENT_MODULE_STATUS_NORMAL_ALERT, $modules_status))) { + return AGENT_STATUS_ALERT_FIRED; + } + // Checking if any module has warning status + elseif (is_int(array_search(AGENT_MODULE_STATUS_WARNING,$modules_status))) { + return AGENT_MODULE_STATUS_WARNING; + } + // Checking if any module has unknown status + elseif (is_int(array_search(AGENT_MODULE_STATUS_UNKNOWN, $modules_status))) { + return AGENT_MODULE_STATUS_UNKNOWN; + } + else { + return AGENT_MODULE_STATUS_NORMAL; + } +} + ?> \ No newline at end of file