2010-08-03 Sergio Martin <sergio.martin@artica.es>
* include/functions_networkmap.php include/functions_db.php: Fixed the networkmaps to do not shows the not init modules and get the new unknown status git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3089 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
8b4627103a
commit
1373cd132b
|
@ -1,3 +1,9 @@
|
|||
2010-08-03 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_networkmap.php
|
||||
include/functions_db.php: Fixed the networkmaps to do not shows
|
||||
the not init modules and get the new unknown status
|
||||
|
||||
2010-08-03 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* operation/agentes/estado_ultimopaquete.php: Fixed log4x modules
|
||||
|
|
|
@ -557,6 +557,30 @@ function get_agentmodule ($id_agentmodule) {
|
|||
return get_db_row ('tagente_modulo', 'id_agente_modulo', (int) $id_agentmodule);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a id of module from his name and the agent id
|
||||
*
|
||||
* @param string agentmodule name to get.
|
||||
* @param int agent id.
|
||||
*
|
||||
* @return int the agentmodule id
|
||||
*/
|
||||
function get_agentmodule_id ($agentmodule_name, $agent_id) {
|
||||
return get_db_row_filter ('tagente_modulo', array('nombre' => $agentmodule_name, 'id_agente' => $agent_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a if a module is init.
|
||||
*
|
||||
* @param int agentmodule id to get.
|
||||
*
|
||||
* @return bool true if is init and false if is not init
|
||||
*/
|
||||
function get_agentmodule_is_init ($id_agentmodule) {
|
||||
$result = get_db_row_filter ('tagente_estado', array('id_agente_modulo' => $id_agentmodule), 'utimestamp');
|
||||
return (bool)$result['utimestamp'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the modules in an agent. If an empty list is passed it will select all
|
||||
*
|
||||
|
@ -584,7 +608,7 @@ $modules = get_agent_modules ($id_agent, '*', 'disabled = 0 AND history_data = 0
|
|||
* @return array An array with all modules in the agent.
|
||||
* If multiple rows are selected, they will be in an array
|
||||
*/
|
||||
function get_agent_modules ($id_agent, $details = false, $filter = false, $indexed = true) {
|
||||
function get_agent_modules ($id_agent, $details = false, $filter = false, $indexed = true, $get_not_init_modules = true) {
|
||||
$id_agent = safe_int ($id_agent, 1);
|
||||
|
||||
$where = '';
|
||||
|
@ -637,6 +661,7 @@ function get_agent_modules ($id_agent, $details = false, $filter = false, $index
|
|||
|
||||
$modules = array ();
|
||||
foreach ($result as $module) {
|
||||
if($get_not_init_modules || get_agentmodule_is_init($module['id_agente_modulo'])) {
|
||||
if (is_array ($details) || $details == '*') {
|
||||
//Just stack the information in array by ID
|
||||
$modules[$module['id_agente_modulo']] = $module;
|
||||
|
@ -644,6 +669,7 @@ function get_agent_modules ($id_agent, $details = false, $filter = false, $index
|
|||
$modules[$module['id_agente_modulo']] = $module[$details];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $modules;
|
||||
}
|
||||
|
||||
|
@ -2628,26 +2654,7 @@ function get_agentmodule_status ($id_agentmodule = 0) {
|
|||
|
||||
$status_row = get_db_row ("tagente_estado", "id_agente_modulo", $id_agentmodule);
|
||||
|
||||
/*// Not init or current_interval == 0: Return current status and avoid problems here !
|
||||
if ($status_row["current_interval"] == 0)
|
||||
return $status_row["estado"];*/
|
||||
|
||||
$module_type = get_agentmodule_type($id_agentmodule);
|
||||
|
||||
// Asynchronous and keepalive modules cant be unknown
|
||||
if(($module_type >= 21 && $module_type <= 23) || $module_type == 100) {
|
||||
return $status_row["estado"];
|
||||
}
|
||||
|
||||
// Unknown status
|
||||
if ($status_row["current_interval"] == 0 || ($status_row["current_interval"] * 2) + $status_row["utimestamp"] < $current_timestamp){
|
||||
$status = 3;
|
||||
}
|
||||
else {
|
||||
$status = $status_row['estado'];
|
||||
}
|
||||
|
||||
return $status;
|
||||
return $status_row['estado'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2659,7 +2666,7 @@ function get_agentmodule_status ($id_agentmodule = 0) {
|
|||
* The value -1 is returned in case the agent has exceed its interval.
|
||||
*/
|
||||
function get_agent_status ($id_agent = 0) {
|
||||
$modules = get_agent_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0));
|
||||
$modules = get_agent_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0), true, false);
|
||||
|
||||
$modules_status = array();
|
||||
$modules_async = 0;
|
||||
|
@ -2672,7 +2679,7 @@ function get_agent_status ($id_agent = 0) {
|
|||
}
|
||||
}
|
||||
|
||||
// If all the modules are asynchronous or keep alive, the gruop cannot be unknown
|
||||
// If all the modules are asynchronous or keep alive, the group cannot be unknown
|
||||
if($modules_async < count($modules)) {
|
||||
$time = get_system_time ();
|
||||
$status = get_db_value_filter ('COUNT(*)',
|
||||
|
@ -2685,7 +2692,6 @@ function get_agent_status ($id_agent = 0) {
|
|||
}
|
||||
|
||||
// Status is 0 for normal, 1 for critical, 2 for warning and 3 for unknown. 4 for alert fired
|
||||
|
||||
// Checking if any module has alert fired (4)
|
||||
if(is_int(array_search(4,$modules_status))){
|
||||
return 4;
|
||||
|
|
|
@ -193,7 +193,7 @@ function generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $font_size
|
|||
}
|
||||
|
||||
// Get agent modules data
|
||||
$modules = get_agent_modules ($agent['id_agente'], false, array('disabled' => 0));
|
||||
$modules = get_agent_modules ($agent['id_agente'], false, array('disabled' => 0), true, false);
|
||||
// Parse modules
|
||||
foreach ($modules as $key => $module) {
|
||||
$node_count ++;
|
||||
|
|
Loading…
Reference in New Issue