diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index fdec89b37c..31d1a769fe 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2009-05-28 Esteban Sanchez + + * include/functions_db.php: Return -1 on get_agent_status() on case + the agent last contact has exceed the agent interval. + + * include/functions_visual_map.php: Call get_agent_status() when + an element is to monitor a whole agent. Fixes #2761712 + 2009-05-28 Esteban Sanchez * install.php: Use server address if the db host is not localhost. diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 86175e5ac5..c901a4138f 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -2112,9 +2112,19 @@ function get_agentmodule_status ($id_agentmodule = 0) { * * @param int Id agent to check. * - * @return int Worst status of an agent for all of its modules + * @return int Worst status of an agent for all of its modules. + * The value -1 is returned in case the agent has exceed its interval. */ function get_agent_status ($id_agent = 0) { + $time = get_system_time (); + $status = get_db_value_filter ('COUNT(*)', + 'tagente', + array ('id_agente' => (int) $id_agent, + 'UNIX_TIMESTAMP(ultimo_contacto) + intervalo * 2 > '.$time, + 'UNIX_TIMESTAMP(ultimo_contacto_remoto) + intervalo * 2 > '.$time)); + if (! $status) + return -1; + $status = get_db_sql ("SELECT MAX(estado) FROM tagente_estado, tagente_modulo WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 2cbe26ae90..f1c56128d3 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -51,19 +51,8 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = $status_parent = get_agentmodule_status ($id_agent_module_parent); // Status for a whole agent } elseif ($layout_data['id_agent'] != 0) { - $id_agent = $layout_data['id_agent']; - $agent_interval = get_agent_interval ($id_agent); - $sql = sprintf ('SELECT MAX(estado) - FROM tagente_estado, tagente_modulo - WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 - AND tagente_modulo.id_agente = %d - AND ((module_interval > 0 - AND utimestamp >= UNIX_TIMESTAMP() - module_interval * 2) - OR (module_interval = 0 - AND utimestamp >= UNIX_TIMESTAMP() - %d))', - $id_agent, $agent_interval * 2); - $status = get_db_sql ($sql); + $status = get_agent_status ($layout_data["id_agent"]); + echo '

'.$status.'

'; $status_parent = $status; } else { $status = 3;