diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 7f3183f91c..22e2f72612 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2067,36 +2067,33 @@ function agents_get_addresses($id_agent) function agents_get_status_from_counts($agent) { // Check if in the data there are all the necessary values - if (!isset($agent['normal_count']) - && !isset($agent['warning_count']) - && !isset($agent['critical_count']) - && !isset($agent['unknown_count']) - && !isset($agent['notinit_count']) - && !isset($agent['total_count']) + if (isset($agent['normal_count']) === false + && isset($agent['warning_count']) === false + && isset($agent['critical_count']) === false + && isset($agent['unknown_count']) === false + && isset($agent['notinit_count']) === false + && isset($agent['total_count']) === false ) { return -1; } - // Juanma (05/05/2014) Fix: This status is not init! 0 modules or all not init + // Juanma (05/05/2014) Fix: This status is not init! 0 modules or all not init. if ($agent['notinit_count'] == $agent['total_count']) { - return AGENT_MODULE_STATUS_NOT_INIT; + return AGENT_STATUS_NOT_INIT; } if ($agent['critical_count'] > 0) { - return AGENT_MODULE_STATUS_CRITICAL_BAD; + return AGENT_STATUS_CRITICAL; } else if ($agent['warning_count'] > 0) { - return AGENT_MODULE_STATUS_WARNING; + return AGENT_STATUS_WARNING; } else if ($agent['unknown_count'] > 0) { - return AGENT_MODULE_STATUS_UNKNOWN; + return AGENT_STATUS_UNKNOWN; } else if ($agent['normal_count'] == $agent['total_count']) { - return AGENT_MODULE_STATUS_NORMAL; + return AGENT_STATUS_NORMAL; } else if (($agent['normal_count'] + $agent['notinit_count']) == $agent['total_count']) { - return AGENT_MODULE_STATUS_NORMAL; + return AGENT_STATUS_NORMAL; } - // ~ else if($agent['notinit_count'] == $agent['total_count']) { - // ~ return AGENT_MODULE_STATUS_NORMAL; - // ~ } return -1; } diff --git a/pandora_console/include/lib/Agent.php b/pandora_console/include/lib/Agent.php index e03da4a604..8758e16095 100644 --- a/pandora_console/include/lib/Agent.php +++ b/pandora_console/include/lib/Agent.php @@ -96,6 +96,30 @@ class Agent extends Entity } + /** + * Return last value (status) of the agent. + * + * @return integer Status of the agent. + */ + public function lastStatus() + { + return \agents_get_status_from_counts( + $this->toArray() + ); + } + + + /** + * Return last value (status) of the agent. + * + * @return integer Status of the agent. + */ + public function lastValue() + { + return $this->lastStatus(); + } + + /** * Overrides Entity method. *