Added the get status of any module group.

This commit is contained in:
mdtrooper 2016-04-22 11:14:25 +02:00
parent 0f4dfa5d1d
commit 0de64812c2
2 changed files with 53 additions and 6 deletions

View File

@ -432,12 +432,6 @@ class Networkmap extends Map {
unlink($filename_dot);
unlink($filename_plain);
// ----- END DEPRECATED CODE--------------------------------
switch (get_class($this)) {
case 'NetworkmapEnterprise':
NetworkmapEnterprise::dbSaveNodes();
break;
}
}
}

View File

@ -2240,4 +2240,57 @@ function modules_get_first_contact_date($id_agent_module) {
return $first_date;
}
function modules_get_module_group_status($id_agent, $id_module_group) {
$status_return = null;
$modules = db_get_all_rows_filter('tagente_modulo',
array('id_agente' => $id_agent,
'id_module_group' => $id_module_group));
if (empty($modules))
$module = array();
foreach ($modules as $module) {
$status = modules_get_status($module['id_agente_modulo']);
// This code is copied from the networkmap old code
switch ($status) {
case AGENT_MODULE_STATUS_NORMAL:
if (is_null($status_return)) {
$status_return = AGENT_MODULE_STATUS_NORMAL;
}
elseif ($status_return == AGENT_MODULE_STATUS_ALL) {
$status_return = AGENT_MODULE_STATUS_NORMAL;
}
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD:
$status_return = AGENT_MODULE_STATUS_CRITICAL_BAD;
break;
case AGENT_MODULE_STATUS_WARNING:
if (is_null($status_return)) {
$status_return = AGENT_MODULE_STATUS_NORMAL;
}
elseif ($status_return != AGENT_MODULE_STATUS_CRITICAL_BAD) {
$status_return = AGENT_MODULE_STATUS_WARNING;
}
break;
case AGENT_MODULE_STATUS_NO_DATA:
if (is_null($status_return)) {
$status_return = AGENT_MODULE_STATUS_NO_DATA;
}
elseif (($status_return == AGENT_MODULE_STATUS_NORMAL) ||
($status_return == AGENT_MODULE_STATUS_ALL)) {
$status_return = AGENT_MODULE_STATUS_NO_DATA;
}
break;
default:
$status_return = AGENT_MODULE_STATUS_ALL;
break;
}
}
return $status_return;
}
?>