mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
wip services improvements
This commit is contained in:
parent
faaf14bfd4
commit
ffba7b8285
@ -2067,36 +2067,33 @@ function agents_get_addresses($id_agent)
|
|||||||
function agents_get_status_from_counts($agent)
|
function agents_get_status_from_counts($agent)
|
||||||
{
|
{
|
||||||
// Check if in the data there are all the necessary values
|
// Check if in the data there are all the necessary values
|
||||||
if (!isset($agent['normal_count'])
|
if (isset($agent['normal_count']) === false
|
||||||
&& !isset($agent['warning_count'])
|
&& isset($agent['warning_count']) === false
|
||||||
&& !isset($agent['critical_count'])
|
&& isset($agent['critical_count']) === false
|
||||||
&& !isset($agent['unknown_count'])
|
&& isset($agent['unknown_count']) === false
|
||||||
&& !isset($agent['notinit_count'])
|
&& isset($agent['notinit_count']) === false
|
||||||
&& !isset($agent['total_count'])
|
&& isset($agent['total_count']) === false
|
||||||
) {
|
) {
|
||||||
return -1;
|
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']) {
|
if ($agent['notinit_count'] == $agent['total_count']) {
|
||||||
return AGENT_MODULE_STATUS_NOT_INIT;
|
return AGENT_STATUS_NOT_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($agent['critical_count'] > 0) {
|
if ($agent['critical_count'] > 0) {
|
||||||
return AGENT_MODULE_STATUS_CRITICAL_BAD;
|
return AGENT_STATUS_CRITICAL;
|
||||||
} else if ($agent['warning_count'] > 0) {
|
} else if ($agent['warning_count'] > 0) {
|
||||||
return AGENT_MODULE_STATUS_WARNING;
|
return AGENT_STATUS_WARNING;
|
||||||
} else if ($agent['unknown_count'] > 0) {
|
} else if ($agent['unknown_count'] > 0) {
|
||||||
return AGENT_MODULE_STATUS_UNKNOWN;
|
return AGENT_STATUS_UNKNOWN;
|
||||||
} else if ($agent['normal_count'] == $agent['total_count']) {
|
} 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']) {
|
} 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
* Overrides Entity method.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user