Fixed the functions to get agents not normal or not init in cases of agents with normal status and some modules not init. TICKET: #1791
This commit is contained in:
parent
658bb921e7
commit
a265ec3383
|
@ -251,7 +251,11 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
|||
*
|
||||
* @return mixed An array with all alerts defined for an agent or false in case no allowed groups are specified.
|
||||
*/
|
||||
function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $order = array('field' => 'nombre', 'order' => 'ASC'), $return = false) {
|
||||
function agents_get_agents ($filter = false, $fields = false,
|
||||
$access = 'AR',
|
||||
$order = array('field' => 'nombre', 'order' => 'ASC'),
|
||||
$return = false) {
|
||||
|
||||
global $config;
|
||||
|
||||
if (! is_array ($filter)) {
|
||||
|
@ -297,7 +301,11 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
|
|||
AND unknown_count > 0";
|
||||
break;
|
||||
case AGENT_STATUS_NOT_NORMAL:
|
||||
$status_sql = "normal_count <> total_count";
|
||||
$status_sql =
|
||||
"(
|
||||
normal_count <> total_count
|
||||
AND
|
||||
(normal_count + notinit_count) <> total_count)";
|
||||
break;
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
$status_sql = "notinit_count = total_count";
|
||||
|
|
|
@ -1158,24 +1158,36 @@ function groups_agent_not_init ($group_array, $strict_user = false, $id_group_st
|
|||
$group_clause = "(" . $group_clause . ")";
|
||||
|
||||
if ($strict_user) {
|
||||
$tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo
|
||||
WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))";
|
||||
$sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0
|
||||
AND id_grupo=$id_group_strict
|
||||
$tags_clause = " AND tagente.id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo NOT IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM ttag_module))";
|
||||
|
||||
$sql = "
|
||||
SELECT COUNT(*)
|
||||
FROM tagente
|
||||
WHERE tagente.disabled = 0
|
||||
AND id_grupo = $id_group_strict
|
||||
AND critical_count = 0
|
||||
AND warning_count = 0
|
||||
AND unknown_count = 0
|
||||
AND normal_count = 0
|
||||
AND (notinit_count > 0 OR total_count = 0)
|
||||
$tags_clause";
|
||||
|
||||
$count = db_get_sql ($sql);
|
||||
} else {
|
||||
$count = db_get_sql ("SELECT COUNT(*)
|
||||
}
|
||||
else {
|
||||
$count = db_get_sql ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente
|
||||
WHERE disabled = 0
|
||||
AND critical_count = 0
|
||||
AND warning_count = 0
|
||||
AND unknown_count = 0
|
||||
AND normal_count = 0
|
||||
AND (notinit_count > 0 OR total_count = 0)
|
||||
AND id_grupo IN $group_clause");
|
||||
}
|
||||
|
@ -1863,7 +1875,8 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
|
|||
|
||||
if ($user_strict) {
|
||||
$user_groups_ids = implode(',',array_keys($groups_without_tags));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$user_groups_ids = implode(',',array_keys($acltags));
|
||||
}
|
||||
|
||||
|
@ -1920,7 +1933,8 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
|
|||
$list[0]['_agents_critical_'] = 0;
|
||||
$list[0]['_monitors_alerts_'] = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$i = 0;
|
||||
}
|
||||
foreach ($list_groups as $key => $item) {
|
||||
|
@ -2032,14 +2046,16 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
|
|||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$list[$i]['_id_'] = $id;
|
||||
$list[$i]['_name_'] = $item['nombre'];
|
||||
$list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
|
||||
|
@ -2193,7 +2209,8 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
|
|||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
}
|
||||
|
@ -2216,9 +2233,12 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
|
|||
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
|
||||
|
||||
if (! defined ('METACONSOLE')) {
|
||||
$result_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode);
|
||||
$result_list = group_get_data ($id_user, $user_strict, $acltags,
|
||||
$returnAllGroup, $mode);
|
||||
|
||||
return $result_list;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$servers = db_get_all_rows_sql ("
|
||||
SELECT *
|
||||
FROM tmetaconsole_setup
|
||||
|
@ -2234,7 +2254,8 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
|
|||
if (metaconsole_connect($server) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
$server_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode);
|
||||
$server_list = group_get_data ($id_user, $user_strict,
|
||||
$acltags, $returnAllGroup, $mode);
|
||||
|
||||
foreach ($server_list as $server_item) {
|
||||
if (! isset ($result_list[$server_item['_name_']])) {
|
||||
|
@ -2284,7 +2305,8 @@ function groups_get_group_deep ($id_group) {
|
|||
|
||||
if (empty($parents)) {
|
||||
$deep = "";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$deep = str_repeat(" ", count($parents));
|
||||
}
|
||||
|
||||
|
|
|
@ -374,17 +374,20 @@ if ($strict_user) {
|
|||
|
||||
$total_agents = count($agents);
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$total_agents = 0;
|
||||
$agents = false;
|
||||
|
||||
|
||||
$total_agents = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $groups,
|
||||
'search' => $search_sql,
|
||||
'status' => $status),
|
||||
array ('COUNT(*) as total'), 'AR', false);
|
||||
$total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0;
|
||||
$total_agents = isset ($total_agents[0]['total']) ?
|
||||
$total_agents[0]['total'] : 0;
|
||||
|
||||
$agents = agents_get_agents(array (
|
||||
'order' => 'nombre ' . $order_collation . ' ASC',
|
||||
|
@ -418,7 +421,8 @@ if (empty ($agents)) {
|
|||
}
|
||||
|
||||
// Prepare pagination
|
||||
ui_pagination ($total_agents, ui_get_url_refresh (array ('group_id' => $group_id, 'recursion' => $recursion, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort, 'status' => $status)));
|
||||
ui_pagination ($total_agents,
|
||||
ui_get_url_refresh (array ('group_id' => $group_id, 'recursion' => $recursion, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort, 'status' => $status)));
|
||||
|
||||
// Show data.
|
||||
$table->cellpadding = 4;
|
||||
|
|
|
@ -67,7 +67,8 @@ ui_print_page_header (__("Group view"), "images/group.png", false, "", false, $u
|
|||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
//Groups and tags
|
||||
$result_groups = group_get_groups_list($config['id_user'], $strict_user, 'AR', true, true);
|
||||
$result_groups = group_get_groups_list($config['id_user'], $strict_user,
|
||||
'AR', true, true);
|
||||
|
||||
$count = count($result_groups);
|
||||
|
||||
|
|
Loading…
Reference in New Issue