Fixed the not init agents in the tree group view. Ticket: #1584
This commit is contained in:
parent
d9e24b9db5
commit
28f68531a1
|
@ -1172,13 +1172,10 @@ function groups_agent_unknown ($group_array) {
|
||||||
return $count > 0 ? $count : 0;
|
return $count > 0 ? $count : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get ok agents by using the status code in modules.
|
function groups_agent_total($group_array) {
|
||||||
|
|
||||||
function groups_agent_ok ($group_array) {
|
|
||||||
|
|
||||||
if (empty ($group_array)) {
|
if (empty ($group_array)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!is_array ($group_array)) {
|
else if (!is_array ($group_array)) {
|
||||||
$group_array = array($group_array);
|
$group_array = array($group_array);
|
||||||
|
@ -1187,7 +1184,34 @@ function groups_agent_ok ($group_array) {
|
||||||
$group_clause = implode (",", $group_array);
|
$group_clause = implode (",", $group_array);
|
||||||
$group_clause = "(" . $group_clause . ")";
|
$group_clause = "(" . $group_clause . ")";
|
||||||
|
|
||||||
$count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND normal_count=total_count AND id_grupo IN $group_clause");
|
$count = db_get_sql ("SELECT COUNT(*)
|
||||||
|
FROM tagente
|
||||||
|
WHERE tagente.disabled = 0
|
||||||
|
AND id_grupo IN $group_clause");
|
||||||
|
|
||||||
|
return $count > 0 ? $count : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get ok agents by using the status code in modules.
|
||||||
|
|
||||||
|
function groups_agent_ok ($group_array) {
|
||||||
|
|
||||||
|
if (empty ($group_array)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (!is_array ($group_array)) {
|
||||||
|
$group_array = array($group_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
$group_clause = implode (",", $group_array);
|
||||||
|
$group_clause = "(" . $group_clause . ")";
|
||||||
|
|
||||||
|
$count = db_get_sql ("SELECT COUNT(*)
|
||||||
|
FROM tagente
|
||||||
|
WHERE tagente.disabled = 0
|
||||||
|
AND normal_count = total_count
|
||||||
|
AND (notinit_count != 0)
|
||||||
|
AND id_grupo IN $group_clause");
|
||||||
|
|
||||||
return $count > 0 ? $count : 0;
|
return $count > 0 ? $count : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7749,7 +7749,7 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $
|
||||||
$out = '';
|
$out = '';
|
||||||
|
|
||||||
// Depend the type of object, the stats will refer agents, modules...
|
// Depend the type of object, the stats will refer agents, modules...
|
||||||
switch($type) {
|
switch ($type) {
|
||||||
case 'agent':
|
case 'agent':
|
||||||
$template_title['total_count'] = __('%d Total modules');
|
$template_title['total_count'] = __('%d Total modules');
|
||||||
$template_title['normal_count'] = __('%d Normal modules');
|
$template_title['normal_count'] = __('%d Normal modules');
|
||||||
|
@ -7764,6 +7764,7 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $
|
||||||
$template_title['critical_count'] = __('%d Critical agents');
|
$template_title['critical_count'] = __('%d Critical agents');
|
||||||
$template_title['warning_count'] = __('%d Warning agents');
|
$template_title['warning_count'] = __('%d Warning agents');
|
||||||
$template_title['unknown_count'] = __('%d Unknown agents');
|
$template_title['unknown_count'] = __('%d Unknown agents');
|
||||||
|
$template_title['not_init_count'] = __('%d not init agents');
|
||||||
$template_title['fired_count'] = __('%d Fired alerts');
|
$template_title['fired_count'] = __('%d Fired alerts');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -7797,6 +7798,13 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $
|
||||||
$stats[] = array('name' => 'unknown_count', 'count' => $unknown_count, 'title' => sprintf($template_title['unknown_count'], $unknown_count));
|
$stats[] = array('name' => 'unknown_count', 'count' => $unknown_count, 'title' => sprintf($template_title['unknown_count'], $unknown_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($counts_info['not_init_count'])) {
|
||||||
|
$not_init_count = $counts_info['not_init_count'];
|
||||||
|
$stats[] = array('name' => 'not_init_count',
|
||||||
|
'count' => $not_init_count,
|
||||||
|
'title' => sprintf($template_title['not_init_count'], $not_init_count));
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($counts_info['fired_count'])) {
|
if (isset($counts_info['fired_count'])) {
|
||||||
$fired_count = $counts_info['fired_count'];
|
$fired_count = $counts_info['fired_count'];
|
||||||
$stats[] = array('name' => 'fired_count', 'count' => $fired_count, 'title' => sprintf($template_title['fired_count'], $fired_count));
|
$stats[] = array('name' => 'fired_count', 'count' => $fired_count, 'title' => sprintf($template_title['fired_count'], $fired_count));
|
||||||
|
@ -7826,6 +7834,8 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $
|
||||||
$out .= ' ' . $separator . ' <span class="yellow forced_title" id="warning_count_' . $uniq_id . '" style="font-size: 7pt">' . $warning_count . '</span>';
|
$out .= ' ' . $separator . ' <span class="yellow forced_title" id="warning_count_' . $uniq_id . '" style="font-size: 7pt">' . $warning_count . '</span>';
|
||||||
if (isset($unknown_count) && $unknown_count > 0)
|
if (isset($unknown_count) && $unknown_count > 0)
|
||||||
$out .= ' ' . $separator . ' <span class="grey forced_title" id="unknown_count_' . $uniq_id . '" style="font-size: 7pt">' . $unknown_count . '</span>';
|
$out .= ' ' . $separator . ' <span class="grey forced_title" id="unknown_count_' . $uniq_id . '" style="font-size: 7pt">' . $unknown_count . '</span>';
|
||||||
|
if (isset($not_init_count) && $not_init_count > 0)
|
||||||
|
$out .= ' ' . $separator . ' <span class="blue forced_title" id="not_init_count_' . $uniq_id . '" style="font-size: 7pt">' . $not_init_count . '</span>';
|
||||||
if (isset($normal_count) && $normal_count > 0)
|
if (isset($normal_count) && $normal_count > 0)
|
||||||
$out .= ' ' . $separator . ' <span class="green forced_title" id="normal_count_' . $uniq_id . '" style="font-size: 7pt">' . $normal_count . '</span>';
|
$out .= ' ' . $separator . ' <span class="green forced_title" id="normal_count_' . $uniq_id . '" style="font-size: 7pt">' . $normal_count . '</span>';
|
||||||
|
|
||||||
|
|
|
@ -477,9 +477,7 @@ function treeview_printTree($type) {
|
||||||
|
|
||||||
|
|
||||||
if (! defined ('METACONSOLE')) {
|
if (! defined ('METACONSOLE')) {
|
||||||
|
|
||||||
$list = treeview_getData ($type);
|
$list = treeview_getData ($type);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$servers = db_get_all_rows_sql ("
|
$servers = db_get_all_rows_sql ("
|
||||||
|
@ -568,11 +566,13 @@ function treeview_printTree($type) {
|
||||||
'total_count' => $item['_num_ok_'] +
|
'total_count' => $item['_num_ok_'] +
|
||||||
$item['_num_critical_'] +
|
$item['_num_critical_'] +
|
||||||
$item['_num_warning_'] +
|
$item['_num_warning_'] +
|
||||||
$item['_num_unknown_'],
|
$item['_num_unknown_'] +
|
||||||
|
$item['_num_not_init_'],
|
||||||
'normal_count' => $item['_num_ok_'],
|
'normal_count' => $item['_num_ok_'],
|
||||||
'critical_count' => $item['_num_critical_'],
|
'critical_count' => $item['_num_critical_'],
|
||||||
'warning_count' => $item['_num_warning_'],
|
'warning_count' => $item['_num_warning_'],
|
||||||
'unknown_count' => $item['_num_unknown_']);
|
'unknown_count' => $item['_num_unknown_'],
|
||||||
|
'not_init_count' => $item['_num_not_init_']);
|
||||||
|
|
||||||
|
|
||||||
reporting_tiny_stats($counts_info, false, $type);
|
reporting_tiny_stats($counts_info, false, $type);
|
||||||
|
@ -599,21 +599,21 @@ function treeview_getData ($type) {
|
||||||
$search_free = get_parameter('search_free', '');
|
$search_free = get_parameter('search_free', '');
|
||||||
$select_status = get_parameter('status', -1);
|
$select_status = get_parameter('status', -1);
|
||||||
$search_group = get_parameter('search_group', 0);
|
$search_group = get_parameter('search_group', 0);
|
||||||
|
|
||||||
if ($search_group) {
|
if ($search_group) {
|
||||||
$avariableGroups[$search_group] = groups_get_name($search_group);
|
$avariableGroups[$search_group] = groups_get_name($search_group);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$avariableGroups = users_get_groups ();
|
$avariableGroups = users_get_groups ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get all groups
|
//Get all groups
|
||||||
//$avariableGroups = users_get_groups ();
|
//$avariableGroups = users_get_groups ();
|
||||||
|
|
||||||
//Get all groups with agents
|
//Get all groups with agents
|
||||||
$full_groups = db_get_all_rows_sql("
|
$full_groups = db_get_all_rows_sql("
|
||||||
SELECT DISTINCT id_grupo
|
SELECT DISTINCT id_grupo
|
||||||
FROM tagente
|
FROM tagente");
|
||||||
WHERE total_count > 0");
|
|
||||||
|
|
||||||
if ($full_groups === false) {
|
if ($full_groups === false) {
|
||||||
return array ();
|
return array ();
|
||||||
|
@ -627,10 +627,12 @@ function treeview_getData ($type) {
|
||||||
|
|
||||||
// We only want groups with agents, so we need the intesect of both arrays.
|
// We only want groups with agents, so we need the intesect of both arrays.
|
||||||
// Not for policies, we need all groups
|
// Not for policies, we need all groups
|
||||||
if ($type != 'policies')
|
if ($type != 'policies') {
|
||||||
$avariableGroups = array_intersect_key($avariableGroups, $fgroups);
|
$avariableGroups = array_intersect_key($avariableGroups,
|
||||||
|
$fgroups);
|
||||||
|
}
|
||||||
|
|
||||||
$avariableGroupsIds = implode(',',array_keys($avariableGroups));
|
$avariableGroupsIds = implode(',', array_keys($avariableGroups));
|
||||||
if ($avariableGroupsIds == '') {
|
if ($avariableGroupsIds == '') {
|
||||||
$avariableGroupsIds == -1;
|
$avariableGroupsIds == -1;
|
||||||
}
|
}
|
||||||
|
@ -692,6 +694,19 @@ function treeview_getData ($type) {
|
||||||
unset($avariableGroups[$id_group]);
|
unset($avariableGroups[$id_group]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NOT_INIT:
|
||||||
|
foreach ($avariableGroups as $group_name) {
|
||||||
|
$id_group = db_get_value_sql('
|
||||||
|
SELECT id_grupo
|
||||||
|
FROM tgrupo
|
||||||
|
WHERE nombre ="' . $group_name . '"');
|
||||||
|
|
||||||
|
$num_not_init = groups_agent_not_init($id_group);
|
||||||
|
|
||||||
|
if ($num_not_init <= 0)
|
||||||
|
unset($avariableGroups[$id_group]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are not groups display error and return
|
// If there are not groups display error and return
|
||||||
|
@ -902,7 +917,8 @@ function treeview_getData ($type) {
|
||||||
array_push($list, array('id' => 0, 'name' => 'No policy'));
|
array_push($list, array('id' => 0, 'name' => 'No policy'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql = "SELECT DISTINCT tpolicies.id,
|
$sql = "
|
||||||
|
SELECT DISTINCT tpolicies.id,
|
||||||
tpolicies.name
|
tpolicies.name
|
||||||
FROM tpolicies, tpolicy_modules, tagente_estado,
|
FROM tpolicies, tpolicy_modules, tagente_estado,
|
||||||
tagente, tagente_modulo
|
tagente, tagente_modulo
|
||||||
|
@ -929,7 +945,8 @@ function treeview_getData ($type) {
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
foreach ($list as $policy_element) {
|
foreach ($list as $policy_element) {
|
||||||
|
|
||||||
$policy_agents_ok = policies_agents_ok($policy_element['id']);
|
$policy_agents_ok =
|
||||||
|
policies_agents_ok($policy_element['id']);
|
||||||
|
|
||||||
if ($policy_agents_ok <= 0)
|
if ($policy_agents_ok <= 0)
|
||||||
unset($list[$element]);
|
unset($list[$element]);
|
||||||
|
@ -1104,7 +1121,9 @@ function treeview_getData ($type) {
|
||||||
$list[$key]['_id_'] = $id;
|
$list[$key]['_id_'] = $id;
|
||||||
$list[$key]['_name_'] = $item['nombre'];
|
$list[$key]['_name_'] = $item['nombre'];
|
||||||
$list[$key]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
|
$list[$key]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
|
||||||
|
$list[$key]['_num_total_'] = groups_agent_total($id);
|
||||||
$list[$key]['_num_ok_'] = groups_agent_ok($id);
|
$list[$key]['_num_ok_'] = groups_agent_ok($id);
|
||||||
|
$list[$key]['_num_not_init_'] = groups_agent_not_init($id);
|
||||||
$list[$key]['_num_critical_'] = groups_agent_critical($id);
|
$list[$key]['_num_critical_'] = groups_agent_critical($id);
|
||||||
$list[$key]['_num_warning_'] = groups_agent_warning($id);
|
$list[$key]['_num_warning_'] = groups_agent_warning($id);
|
||||||
$list[$key]['_num_unknown_'] = groups_agent_unknown ($id);
|
$list[$key]['_num_unknown_'] = groups_agent_unknown ($id);
|
||||||
|
|
|
@ -973,6 +973,10 @@ tr.disabled_row_user * {
|
||||||
color: #808080;
|
color: #808080;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.blue {
|
||||||
|
color: #5AB7E5;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
.redb, .greenb, td.datos_id, td.datos2_id, f9b {
|
.redb, .greenb, td.datos_id, td.datos2_id, f9b {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ define('NORMAL', 0);
|
||||||
define('WARNING', 2);
|
define('WARNING', 2);
|
||||||
define('CRITICAL', 1);
|
define('CRITICAL', 1);
|
||||||
define('UNKNOWN', 3);
|
define('UNKNOWN', 3);
|
||||||
|
define('NOT_INIT', 5);
|
||||||
|
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -562,7 +564,13 @@ switch ($activeTab) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! defined ('METACONSOLE')) {
|
if (! defined ('METACONSOLE')) {
|
||||||
$onheader = array('tag' => $tags_tab, 'os' => $os_tab, 'group' => $group_tab, 'module_group' => $module_group_tab, 'policies' => $policies_tab, 'module' => $module_tab);
|
$onheader = array('tag' => $tags_tab,
|
||||||
|
'os' => $os_tab,
|
||||||
|
'group' => $group_tab,
|
||||||
|
'module_group' => $module_group_tab,
|
||||||
|
'policies' => $policies_tab,
|
||||||
|
'module' => $module_tab);
|
||||||
|
|
||||||
ui_print_page_header(
|
ui_print_page_header(
|
||||||
__('Tree view') . " - " . __('Sort the agents by ') . $order,
|
__('Tree view') . " - " . __('Sort the agents by ') . $order,
|
||||||
"images/extensions.png",
|
"images/extensions.png",
|
||||||
|
@ -570,7 +578,9 @@ if (! defined ('METACONSOLE')) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
ui_meta_add_breadcrumb(array('link' => 'index.php?sec=monitoring&sec2=operation/tree', 'text' => __('Tree View')));
|
ui_meta_add_breadcrumb(array(
|
||||||
|
'link' => 'index.php?sec=monitoring&sec2=operation/tree',
|
||||||
|
'text' => __('Tree View')));
|
||||||
ui_meta_print_page_header($nav_bar);
|
ui_meta_print_page_header($nav_bar);
|
||||||
|
|
||||||
$img_style = array ("class" => "top", "width" => 16);
|
$img_style = array ("class" => "top", "width" => 16);
|
||||||
|
@ -585,14 +595,16 @@ else {
|
||||||
|
|
||||||
if (!in_array($activeTab, $allowed_tabs)) {
|
if (!in_array($activeTab, $allowed_tabs)) {
|
||||||
db_pandora_audit("HACK Attempt",
|
db_pandora_audit("HACK Attempt",
|
||||||
"Trying to access to not allowed tab on tree view");
|
"Trying to access to not allowed tab on tree view");
|
||||||
include ("general/noaccess.php");
|
include ("general/noaccess.php");
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// End of tab check
|
// End of tab check
|
||||||
|
|
||||||
$group_tab = array('text' => "<a href='index.php?sec=monitoring&sec2=operation/tree&refr=0&tab=group&pure=$pure'>"
|
$group_tab = array('text' => "<a href='index.php?sec=monitoring&sec2=operation/tree&refr=0&tab=group&pure=$pure'>"
|
||||||
. html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "</a>",
|
. html_print_image ("images/group.png", true,
|
||||||
|
array ("title" => __('Groups'))) . "</a>",
|
||||||
'active' => $activeTab == "group");
|
'active' => $activeTab == "group");
|
||||||
|
|
||||||
$subsections['group'] = $group_tab;
|
$subsections['group'] = $group_tab;
|
||||||
|
@ -600,7 +612,8 @@ else {
|
||||||
if ($config['enable_tags_tree']) {
|
if ($config['enable_tags_tree']) {
|
||||||
$tags_tab = array(
|
$tags_tab = array(
|
||||||
'text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&tab=tag&pure=$pure'>" .
|
'text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&tab=tag&pure=$pure'>" .
|
||||||
html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "</a>",
|
html_print_image ("images/tag.png", true,
|
||||||
|
array ("title" => __('Tags'))) . "</a>",
|
||||||
'active' => $activeTab == "tag");
|
'active' => $activeTab == "tag");
|
||||||
|
|
||||||
$subsections['tag'] = $tags_tab;
|
$subsections['tag'] = $tags_tab;
|
||||||
|
@ -644,6 +657,7 @@ $fields[NORMAL] = __('Normal');
|
||||||
$fields[WARNING] = __('Warning');
|
$fields[WARNING] = __('Warning');
|
||||||
$fields[CRITICAL] = __('Critical');
|
$fields[CRITICAL] = __('Critical');
|
||||||
$fields[UNKNOWN] = __('Unknown');
|
$fields[UNKNOWN] = __('Unknown');
|
||||||
|
$fields[NOT_INIT] = __('Not init');
|
||||||
|
|
||||||
html_print_select ($fields, "status", $select_status);
|
html_print_select ($fields, "status", $select_status);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue