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:
mdtrooper 2015-02-10 18:24:00 +01:00
parent 658bb921e7
commit a265ec3383
4 changed files with 104 additions and 69 deletions

View File

@ -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. * @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; global $config;
if (! is_array ($filter)) { if (! is_array ($filter)) {
@ -297,7 +301,11 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
AND unknown_count > 0"; AND unknown_count > 0";
break; break;
case AGENT_STATUS_NOT_NORMAL: 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; break;
case AGENT_STATUS_NOT_INIT: case AGENT_STATUS_NOT_INIT:
$status_sql = "notinit_count = total_count"; $status_sql = "notinit_count = total_count";

View File

@ -1158,24 +1158,36 @@ function groups_agent_not_init ($group_array, $strict_user = false, $id_group_st
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) { if ($strict_user) {
$tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo $tags_clause = " AND tagente.id_agente IN (
WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; SELECT id_agente
$sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 FROM tagente_modulo
AND id_grupo=$id_group_strict WHERE id_agente_modulo NOT IN (
AND critical_count = 0 SELECT id_agente_modulo
AND warning_count = 0 FROM ttag_module))";
AND unknown_count = 0
AND (notinit_count > 0 OR total_count = 0) $sql = "
$tags_clause"; 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); $count = db_get_sql ($sql);
} else { }
$count = db_get_sql ("SELECT COUNT(*) else {
$count = db_get_sql ("
SELECT COUNT(*)
FROM tagente FROM tagente
WHERE disabled = 0 WHERE disabled = 0
AND critical_count = 0 AND critical_count = 0
AND warning_count = 0 AND warning_count = 0
AND unknown_count = 0 AND unknown_count = 0
AND normal_count = 0
AND (notinit_count > 0 OR total_count = 0) AND (notinit_count > 0 OR total_count = 0)
AND id_grupo IN $group_clause"); AND id_grupo IN $group_clause");
} }
@ -1860,10 +1872,11 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
} }
} }
} }
if ($user_strict) { if ($user_strict) {
$user_groups_ids = implode(',',array_keys($groups_without_tags)); $user_groups_ids = implode(',',array_keys($groups_without_tags));
} else { }
else {
$user_groups_ids = implode(',',array_keys($acltags)); $user_groups_ids = implode(',',array_keys($acltags));
} }
@ -1892,7 +1905,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
break; break;
} }
} }
$list = array(); $list = array();
if ($list_groups == false) { if ($list_groups == false) {
@ -1903,7 +1916,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$i = 1; $i = 1;
$list[0]['_id_'] = 0; $list[0]['_id_'] = 0;
$list[0]['_name_'] = __('All'); $list[0]['_name_'] = __('All');
$list[0]['_agents_unknown_'] = 0; $list[0]['_agents_unknown_'] = 0;
$list[0]['_monitors_alerts_fired_'] = 0; $list[0]['_monitors_alerts_fired_'] = 0;
$list[0]['_total_agents_'] = 0; $list[0]['_total_agents_'] = 0;
@ -1913,14 +1926,15 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[0]['_monitors_unknown_'] = 0; $list[0]['_monitors_unknown_'] = 0;
$list[0]['_monitors_not_init_'] = 0; $list[0]['_monitors_not_init_'] = 0;
$list[0]['_agents_not_init_'] = 0; $list[0]['_agents_not_init_'] = 0;
if ($mode == 'tactical') { if ($mode == 'tactical') {
$list[0]['_agents_ok_'] = 0; $list[0]['_agents_ok_'] = 0;
$list[0]['_agents_warning_'] = 0; $list[0]['_agents_warning_'] = 0;
$list[0]['_agents_critical_'] = 0; $list[0]['_agents_critical_'] = 0;
$list[0]['_monitors_alerts_'] = 0; $list[0]['_monitors_alerts_'] = 0;
} }
} else { }
else {
$i = 0; $i = 0;
} }
foreach ($list_groups as $key => $item) { foreach ($list_groups as $key => $item) {
@ -1936,10 +1950,10 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]['_id_'] = $id; $list[$i]['_id_'] = $id;
$list[$i]['_name_'] = $item['nombre']; $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;')); $list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
if ($mode == 'tree' && !empty($item['parent'])) if ($mode == 'tree' && !empty($item['parent']))
$list[$i]['_parent_id_'] = $item['parent']; $list[$i]['_parent_id_'] = $item['parent'];
$list[$i]['_agents_unknown_'] = $group_stat[0]["unknown"]; $list[$i]['_agents_unknown_'] = $group_stat[0]["unknown"];
$list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"]; $list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"];
$list[$i]['_total_agents_'] = $group_stat[0]["agents"]; $list[$i]['_total_agents_'] = $group_stat[0]["agents"];
@ -1965,17 +1979,17 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
if ($mode == 'tactical') { if ($mode == 'tactical') {
// Get total count of monitors for this group, except disabled. // Get total count of monitors for this group, except disabled.
$list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"]; $list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"];
// Calculate not_normal monitors // Calculate not_normal monitors
$list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"]; $list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"];
if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); $list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
} }
else { else {
$list[$i]["_monitor_health_"] = 100; $list[$i]["_monitor_health_"] = 100;
} }
if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); $list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
} }
@ -1995,16 +2009,16 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]["_alert_level_"] = 100; $list[$i]["_alert_level_"] = 100;
$list[$i]["_alerts_"] = 0; $list[$i]["_alerts_"] = 0;
} }
$list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"]; $list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"];
if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); $list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
} }
else { else {
$list[$i]["_global_health_"] = 100; $list[$i]["_global_health_"] = 100;
} }
$list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1); $list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1);
} }
@ -2018,7 +2032,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
$list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_']; $list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_'];
$list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_']; $list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_'];
if ($mode == 'tactical' || $mode == 'tree') { if ($mode == 'tactical' || $mode == 'tree') {
$list[0]['_agents_ok_'] += $group_stat[0]["normal"]; $list[0]['_agents_ok_'] += $group_stat[0]["normal"];
$list[0]['_agents_warning_'] += $group_stat[0]["warning"]; $list[0]['_agents_warning_'] += $group_stat[0]["warning"];
@ -2032,21 +2046,23 @@ 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)) { 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]); 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)) { 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]); unset($list[$i]);
} }
} }
} }
} else { }
else {
$list[$i]['_id_'] = $id; $list[$i]['_id_'] = $id;
$list[$i]['_name_'] = $item['nombre']; $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;')); $list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
if ($mode == 'tree' && !empty($item['parent'])) if ($mode == 'tree' && !empty($item['parent']))
$list[$i]['_parent_id_'] = $item['parent']; $list[$i]['_parent_id_'] = $item['parent'];
$list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id); $list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id);
$list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id); $list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id);
$list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id); $list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id);
@ -2069,17 +2085,17 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
// Get total count of monitors for this group, except disabled. // Get total count of monitors for this group, except disabled.
$list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"]; $list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"];
// Calculate not_normal monitors // Calculate not_normal monitors
$list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"]; $list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"];
if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); $list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
} }
else { else {
$list[$i]["_monitor_health_"] = 100; $list[$i]["_monitor_health_"] = 100;
} }
if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); $list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
} }
@ -2099,16 +2115,16 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]["_alert_level_"] = 100; $list[$i]["_alert_level_"] = 100;
$list[$i]["_alerts_"] = 0; $list[$i]["_alerts_"] = 0;
} }
$list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"]; $list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"];
if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); $list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
} }
else { else {
$list[$i]["_global_health_"] = 100; $list[$i]["_global_health_"] = 100;
} }
$list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1); $list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1);
} }
@ -2149,12 +2165,12 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
if ($user_strict) { if ($user_strict) {
foreach ($user_tags as $group_id => $tag_name) { foreach ($user_tags as $group_id => $tag_name) {
$id = db_get_value('id_tag', 'ttag', 'name', $tag_name); $id = db_get_value('id_tag', 'ttag', 'name', $tag_name);
$list[$i]['_id_'] = $id; $list[$i]['_id_'] = $id;
$list[$i]['_name_'] = $tag_name; $list[$i]['_name_'] = $tag_name;
$list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;')); $list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;'));
$list[$i]['_is_tag_'] = 1; $list[$i]['_is_tag_'] = 1;
$list[$i]['_total_agents_'] = tags_total_agents ($id, $acltags); $list[$i]['_total_agents_'] = tags_total_agents ($id, $acltags);
$list[$i]['_agents_unknown_'] = tags_get_unknown_agents ($id, $acltags); $list[$i]['_agents_unknown_'] = tags_get_unknown_agents ($id, $acltags);
$list[$i]['_monitors_ok_'] = tags_monitors_ok ($id, $acltags); $list[$i]['_monitors_ok_'] = tags_monitors_ok ($id, $acltags);
@ -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)) { 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]); 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)) { 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]); unset($list[$i]);
} }
@ -2208,17 +2225,20 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
function group_get_groups_list($id_user = false, $user_strict = false, $access = 'AR', $force_group_and_tag = true, $returnAllGroup = false, $mode = 'group') { function group_get_groups_list($id_user = false, $user_strict = false, $access = 'AR', $force_group_and_tag = true, $returnAllGroup = false, $mode = 'group') {
global $config; global $config;
if ($id_user == false) { if ($id_user == false) {
$id_user = $config['id_user']; $id_user = $config['id_user'];
} }
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict); $acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
if (! defined ('METACONSOLE')) { 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; return $result_list;
} else { }
else {
$servers = db_get_all_rows_sql (" $servers = db_get_all_rows_sql ("
SELECT * SELECT *
FROM tmetaconsole_setup FROM tmetaconsole_setup
@ -2230,15 +2250,16 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
$result_list = array (); $result_list = array ();
foreach ($servers as $server) { foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) { if (metaconsole_connect($server) != NOERR) {
continue; 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) { foreach ($server_list as $server_item) {
if (! isset ($result_list[$server_item['_name_']])) { if (! isset ($result_list[$server_item['_name_']])) {
$result_list[$server_item['_name_']] = $server_item; $result_list[$server_item['_name_']] = $server_item;
} }
else { else {
@ -2271,9 +2292,9 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
} }
} }
metaconsole_restore_db(); metaconsole_restore_db();
} }
return $result_list; return $result_list;
} }
} }
@ -2284,7 +2305,8 @@ function groups_get_group_deep ($id_group) {
if (empty($parents)) { if (empty($parents)) {
$deep = ""; $deep = "";
} else { }
else {
$deep = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", count($parents)); $deep = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", count($parents));
} }

View File

@ -348,7 +348,7 @@ else {
if ($strict_user) { if ($strict_user) {
$filter = array ( $filter = array (
'order' => 'tagente.nombre COLLATE utf8_general_ci ASC', 'order' => 'tagente.nombre COLLATE utf8_general_ci ASC',
'disabled' => 0, 'disabled' => 0,
@ -364,27 +364,30 @@ if ($strict_user) {
} }
$filter['id_group'] = implode(',', $groups); $filter['id_group'] = implode(',', $groups);
} }
$fields = array ('tagente.id_agente','tagente.id_grupo','tagente.id_os','tagente.ultimo_contacto','tagente.intervalo','tagente.comentarios description','tagente.quiet', $fields = array ('tagente.id_agente','tagente.id_grupo','tagente.id_os','tagente.ultimo_contacto','tagente.intervalo','tagente.comentarios description','tagente.quiet',
'tagente.normal_count','tagente.warning_count','tagente.critical_count','tagente.unknown_count','tagente.notinit_count','tagente.total_count','tagente.fired_count'); 'tagente.normal_count','tagente.warning_count','tagente.critical_count','tagente.unknown_count','tagente.notinit_count','tagente.total_count','tagente.fired_count');
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user); $acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true); $agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
$total_agents = count($agents); $total_agents = count($agents);
} else { }
else {
$total_agents = 0; $total_agents = 0;
$agents = false; $agents = false;
$total_agents = agents_get_agents(array ( $total_agents = agents_get_agents(array (
'disabled' => 0, 'disabled' => 0,
'id_grupo' => $groups, 'id_grupo' => $groups,
'search' => $search_sql, 'search' => $search_sql,
'status' => $status), 'status' => $status),
array ('COUNT(*) as total'), 'AR', false); 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 ( $agents = agents_get_agents(array (
'order' => 'nombre ' . $order_collation . ' ASC', 'order' => 'nombre ' . $order_collation . ' ASC',
@ -418,7 +421,8 @@ if (empty ($agents)) {
} }
// Prepare pagination // 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. // Show data.
$table->cellpadding = 4; $table->cellpadding = 4;

View File

@ -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']); $strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
//Groups and tags //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); $count = count($result_groups);
@ -95,7 +96,7 @@ if (!empty($result_groups)) {
echo "<th width='10%' style='min-width: 60px;'>" . __("Alert fired") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Alert fired") . "</th>";
foreach ($result_groups as $data) { foreach ($result_groups as $data) {
// Calculate entire row color // Calculate entire row color
if ($data["_monitors_alerts_fired_"] > 0){ if ($data["_monitors_alerts_fired_"] > 0){
$color_class = 'group_view_alrm'; $color_class = 'group_view_alrm';
@ -150,13 +151,13 @@ if (!empty($result_groups)) {
} }
$group_name = "<b><span style='font-size: 7.5pt'>" . ui_print_truncate_text($data['_name_'], 50) . "</span></b>"; $group_name = "<b><span style='font-size: 7.5pt'>" . ui_print_truncate_text($data['_name_'], 50) . "</span></b>";
$item_icon = ''; $item_icon = '';
if (isset($data['_iconImg_']) && !empty($data['_iconImg_'])) if (isset($data['_iconImg_']) && !empty($data['_iconImg_']))
$item_icon = $data['_iconImg_']; $item_icon = $data['_iconImg_'];
echo $link . $deep . $item_icon ."&nbsp;" . $group_name . "</a>"; echo $link . $deep . $item_icon ."&nbsp;" . $group_name . "</a>";
echo "</td>"; echo "</td>";
// Total agents // Total agents