2009-05-28 Esteban Sanchez <estebans@artica.es>

* 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



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1720 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2009-05-28 13:28:36 +00:00
parent d3019cb494
commit 3f6e55854a
3 changed files with 21 additions and 14 deletions

View File

@ -1,3 +1,11 @@
2009-05-28 Esteban Sanchez <estebans@artica.es>
* 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 <estebans@artica.es>
* install.php: Use server address if the db host is not localhost.

View File

@ -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

View File

@ -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 '<h1>'.$status.'</h1>';
$status_parent = $status;
} else {
$status = 3;