[Secondary groups] Fixed duplicated agents in group view and agent detail
This commit is contained in:
parent
d36ab81d6c
commit
c88e6e703a
|
@ -475,7 +475,7 @@ function agents_get_agents ($filter = false, $fields = false,
|
|||
$where = sprintf('%s AND %s AND (%s) %s AND %s %s',
|
||||
$where, $where_nogroup, $status_sql, $search, $disabled, $search_custom);
|
||||
}
|
||||
$sql = sprintf('SELECT %s
|
||||
$sql = sprintf('SELECT DISTINCT %s
|
||||
FROM tagente LEFT JOIN tagent_secondary_group ON tagent_secondary_group.id_agent=tagente.id_agente
|
||||
WHERE %s %s', implode(',',$fields), $where, $order);
|
||||
|
||||
|
|
|
@ -845,7 +845,7 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret
|
|||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$sql = sprintf ("SELECT *
|
||||
$sql = sprintf ("SELECT DISTINCT tevento.*
|
||||
FROM tevento LEFT JOIN tagent_secondary_group tasg ON tevento.id_agente = tasg.id_agent
|
||||
WHERE %s %s
|
||||
ORDER BY utimestamp DESC LIMIT %d", $agent_condition, $filter, $limit);
|
||||
|
@ -857,7 +857,7 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret
|
|||
ORDER BY utimestamp DESC", $agent_condition, $filter, $limit);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
|
||||
if ($result === false) {
|
||||
|
|
|
@ -123,7 +123,7 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
* Agent cache for metaconsole.
|
||||
* Retrieve the statistic data from the cache table.
|
||||
*/
|
||||
if (!$user_strict && is_metaconsole()) {
|
||||
if (is_metaconsole()) {
|
||||
foreach ($list_groups as $group) {
|
||||
$group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
||||
SUM(critical_count) AS _monitors_critical_,
|
||||
|
@ -181,7 +181,7 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (($config["realtimestats"] == 0) && !$user_strict) {
|
||||
else if (($config["realtimestats"] == 0)) {
|
||||
|
||||
$group_stat = db_get_all_rows_sql ("SELECT
|
||||
SUM(ta.normal_count) as normal, SUM(ta.critical_count) as critical,
|
||||
|
@ -253,24 +253,24 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_NOT_INIT),
|
||||
array ('COUNT(*) as total'), $access, false);
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = isset ($agent_not_init[0]['total']) ? $agent_not_init[0]['total'] : 0;
|
||||
$agent_unknown = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_UNKNOWN),
|
||||
array ('COUNT(*) as total'), $access, false);
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0;
|
||||
$agent_critical = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_CRITICAL),
|
||||
array ('COUNT(*) as total'), $access, false);
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_critical_'] = isset ($agent_critical[0]['total']) ? $agent_critical[0]['total'] : 0;
|
||||
$agent_total = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo']),
|
||||
array ('COUNT(*) as total'), $access, false);
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = groupview_monitor_fired_alerts ($group['id_grupo'], $user_strict,array($group['id_grupo']));
|
||||
|
@ -328,41 +328,6 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = isset ($result_not_init['contado']) ? $result_not_init['contado'] : 0;
|
||||
}
|
||||
|
||||
if ($user_strict) {
|
||||
$i = 1;
|
||||
foreach ($user_tags as $group_id => $tag_name) {
|
||||
$id = db_get_value('id_tag', 'ttag', 'name', $tag_name);
|
||||
|
||||
$list[$i]['_id_'] = $id;
|
||||
$list[$i]['_name_'] = $tag_name;
|
||||
$list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;'));
|
||||
$list[$i]['_is_tag_'] = 1;
|
||||
|
||||
$list[$i]['_total_agents_'] = (int) tags_get_total_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_unknown_'] = (int) tags_get_unknown_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_critical_'] = (int) tags_get_critical_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_not_init_'] = (int) tags_get_not_init_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_monitors_ok_'] = (int) tags_get_normal_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_critical_'] = (int) tags_get_critical_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_warning_'] = (int) tags_get_warning_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_not_init_'] = (int) tags_get_not_init_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_unknown_'] = (int) tags_get_unknown_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags);
|
||||
|
||||
if (! defined ('METACONSOLE')) {
|
||||
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 {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
@ -377,63 +342,9 @@ function groupview_status_modules_agents($id_user = false, $user_strict = false,
|
|||
//$acltags = tags_get_user_groups_and_tags ($id_user, $access, $user_strict);
|
||||
$acltags = users_get_groups ($id_user, $access, true, true);
|
||||
|
||||
// If using metaconsole, the strict users will use the agent table of every node
|
||||
if (is_metaconsole() && $user_strict) {
|
||||
$servers = metaconsole_get_servers();
|
||||
|
||||
$result_list = array ();
|
||||
foreach ($servers as $server) {
|
||||
|
||||
if (metaconsole_connect($server) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$server_list = groupview_get_all_data($id_user, $user_strict,
|
||||
$acltags, $returnAllGroup);
|
||||
|
||||
foreach ($server_list as $server_item) {
|
||||
if (! isset ($result_list[$server_item['_name_']])) {
|
||||
|
||||
$result_list[$server_item['_name_']] = $server_item;
|
||||
}
|
||||
else {
|
||||
$result_list[$server_item['_name_']]['_monitors_ok_'] += $server_item['_monitors_ok_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_critical_'] += $server_item['_monitors_critical_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_warning_'] += $server_item['_monitors_warning_'];
|
||||
$result_list[$server_item['_name_']]['_agents_unknown_'] += $server_item['_agents_unknown_'];
|
||||
$result_list[$server_item['_name_']]['_total_agents_'] += $server_item['_total_agents_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_alerts_fired_'] += $server_item['_monitors_alerts_fired_'];
|
||||
|
||||
$result_list[$server_item['_name_']]['_agents_ok_'] += $server_item['_agents_ok_'];
|
||||
$result_list[$server_item['_name_']]['_agents_critical_'] += $server_item['_agents_critical_'];
|
||||
$result_list[$server_item['_name_']]['_agents_warning_'] += $server_item['_agents_warning_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_alerts_'] += $server_item['_monitors_alerts_'];
|
||||
|
||||
$result_list[$server_item['_name_']]["_monitor_checks_"] += $server_item["_monitor_checks_"];
|
||||
$result_list[$server_item['_name_']]["_monitor_not_normal_"] += $server_item["_monitor_not_normal_"];
|
||||
$result_list[$server_item['_name_']]["_monitor_health_"] += $server_item["_monitor_health_"];
|
||||
$result_list[$server_item['_name_']]["_module_sanity_"] += $server_item["_module_sanity_"];
|
||||
$result_list[$server_item['_name_']]["_alerts_"] += $server_item["_alerts_"];
|
||||
$result_list[$server_item['_name_']]["_alert_level_"] += $server_item["_alert_level_"];
|
||||
$result_list[$server_item['_name_']]["_monitor_bad_"] += $server_item["_monitor_bad_"];
|
||||
$result_list[$server_item['_name_']]["_global_health_"] += $server_item["_global_health_"];
|
||||
$result_list[$server_item['_name_']]["_server_sanity_"] += $server_item["_server_sanity_"];
|
||||
$result_list[$server_item['_name_']]["_monitor_alerts_fire_count_"] += $server_item["_monitor_alerts_fire_count_"];
|
||||
$result_list[$server_item['_name_']]["_total_checks_"] += $server_item["_total_checks_"];
|
||||
$result_list[$server_item['_name_']]["_total_alerts_"] += $server_item["_total_alerts_"];
|
||||
}
|
||||
}
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
return $result_list;
|
||||
}
|
||||
else {
|
||||
|
||||
$result_list = groupview_get_all_data ($id_user, $user_strict,
|
||||
$acltags, false, array(), array(), $access);
|
||||
return $result_list;
|
||||
}
|
||||
$result_list = groupview_get_all_data ($id_user, $user_strict,
|
||||
$acltags, false, array(), array(), $access);
|
||||
return $result_list;
|
||||
}
|
||||
|
||||
function groupview_monitor_alerts ($group_array, $strict_user = false, $id_group_strict = false) {
|
||||
|
@ -521,52 +432,11 @@ function groupview_get_groups_list($id_user = false, $user_strict = false, $acce
|
|||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
//$acltags = tags_get_user_groups_and_tags ($id_user, $access, $user_strict);
|
||||
//
|
||||
|
||||
|
||||
$acltags = users_get_groups($id_user, $access, true, true);
|
||||
$result_list = groupview_get_data ($id_user, $user_strict, $acltags,
|
||||
$returnAllGroup, array(), array(), $access);
|
||||
|
||||
// If using metaconsole, the strict users will use the agent table of every node
|
||||
if (is_metaconsole() && $user_strict) {
|
||||
$servers = metaconsole_get_servers();
|
||||
|
||||
$result_list = array ();
|
||||
foreach ($servers as $server) {
|
||||
|
||||
if (metaconsole_connect($server) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
$server_list = groupview_get_data ($id_user, $user_strict,
|
||||
$acltags, $returnAllGroup);
|
||||
|
||||
foreach ($server_list as $server_item) {
|
||||
if (! isset ($result_list[$server_item['_name_']])) {
|
||||
|
||||
$result_list[$server_item['_name_']] = $server_item;
|
||||
}
|
||||
else {
|
||||
$result_list[$server_item['_name_']]['_monitors_ok_'] += $server_item['_monitors_ok_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_critical_'] += $server_item['_monitors_critical_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_warning_'] += $server_item['_monitors_warning_'];
|
||||
$result_list[$server_item['_name_']]['_agents_unknown_'] += $server_item['_agents_unknown_'];
|
||||
$result_list[$server_item['_name_']]['_total_agents_'] += $server_item['_total_agents_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_alerts_fired_'] += $server_item['_monitors_alerts_fired_'];
|
||||
}
|
||||
}
|
||||
metaconsole_restore_db();
|
||||
|
||||
}
|
||||
|
||||
return $result_list;
|
||||
}
|
||||
// If using metaconsole, the not strict users will use the metaconsole's agent cache table
|
||||
else {
|
||||
$result_list = groupview_get_data ($id_user, $user_strict, $acltags,
|
||||
$returnAllGroup, array(), array(), $access);
|
||||
|
||||
return $result_list;
|
||||
}
|
||||
return $result_list;
|
||||
}
|
||||
|
||||
function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $agent_filter = array(), $module_filter = array(), $access = 'AR') {
|
||||
|
@ -598,7 +468,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
$user_groups_ids = implode(',', array_keys($acltags));
|
||||
|
||||
if (!empty($user_groups_ids)) {
|
||||
if (is_metaconsole() && (!$user_strict)) {
|
||||
if (is_metaconsole()) {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
|
@ -744,7 +614,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
$list_groups = array();
|
||||
}
|
||||
|
||||
if (!$user_strict && is_metaconsole()) { // Agent cache
|
||||
if (is_metaconsole()) { // Agent cache
|
||||
foreach ($list_groups as $group) {
|
||||
$group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
||||
SUM(critical_count) AS _monitors_critical_,
|
||||
|
@ -808,7 +678,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (($config["realtimestats"] == 0) && !$user_strict) {
|
||||
else if (($config["realtimestats"] == 0)) {
|
||||
|
||||
$group_stat = db_get_all_rows_sql ("SELECT
|
||||
SUM(ta.normal_count) as normal, SUM(ta.critical_count) as critical,
|
||||
|
@ -880,24 +750,24 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_NOT_INIT),
|
||||
array ('COUNT(*) as total'), $access, false);
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = isset ($agent_not_init[0]['total']) ? $agent_not_init[0]['total'] : 0;
|
||||
$agent_unknown = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_UNKNOWN),
|
||||
array ('COUNT(*) as total'), $access, false);
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0;
|
||||
$agent_critical = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_CRITICAL),
|
||||
array ('COUNT(*) as total'), $access, false);
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_agents_critical_'] = isset ($agent_critical[0]['total']) ? $agent_critical[0]['total'] : 0;
|
||||
$agent_total = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo']),
|
||||
array ('COUNT(*) as total'), $access, false);
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
|
|
@ -81,7 +81,6 @@ function tactical_get_data ($id_user = false, $user_strict = false, $acltags, $r
|
|||
$list['_monitors_not_init_'] = 0;
|
||||
$list['_monitors_ok_'] = 0;
|
||||
|
||||
|
||||
if (empty($list_groups)) {
|
||||
$list_groups = array();
|
||||
}
|
||||
|
@ -90,7 +89,7 @@ function tactical_get_data ($id_user = false, $user_strict = false, $acltags, $r
|
|||
* Agent cache for metaconsole.
|
||||
* Retrieve the statistic data from the cache table.
|
||||
*/
|
||||
if (!$user_strict && is_metaconsole() && !empty($list_groups)) {
|
||||
if (is_metaconsole() && !empty($list_groups)) {
|
||||
$cache_table = 'tmetaconsole_agent';
|
||||
|
||||
$sql_stats = "SELECT id_grupo, COUNT(id_agente) AS agents_total,
|
||||
|
@ -197,7 +196,7 @@ function tactical_get_data ($id_user = false, $user_strict = false, $acltags, $r
|
|||
}
|
||||
}
|
||||
|
||||
if (!$user_strict && is_metaconsole()) { // Agent cache
|
||||
if (is_metaconsole()) { // Agent cache
|
||||
// Get total count of monitors for this group, except disabled.
|
||||
$list["_monitor_checks_"] = $list["_monitors_not_init_"] + $list["_monitors_unknown_"] + $list["_monitors_warning_"] + $list["_monitors_critical_"] + $list["_monitors_ok_"];
|
||||
|
||||
|
@ -243,7 +242,7 @@ function tactical_get_data ($id_user = false, $user_strict = false, $acltags, $r
|
|||
$list["_server_sanity_"] = format_numeric (100 - $list["_module_sanity_"], 1);
|
||||
|
||||
}
|
||||
else if (($config["realtimestats"] == 0) && !$user_strict) {
|
||||
else if (($config["realtimestats"] == 0)) {
|
||||
|
||||
$group_stat = db_get_all_rows_sql ("SELECT
|
||||
SUM(ta.normal_count) as normal, SUM(ta.critical_count) as critical,
|
||||
|
@ -251,10 +250,10 @@ function tactical_get_data ($id_user = false, $user_strict = false, $acltags, $r
|
|||
SUM(ta.notinit_count) as not_init, SUM(fired_count) as alerts_fired
|
||||
FROM tagente ta
|
||||
WHERE disabled = 0 AND id_grupo IN ($user_groups_ids)");
|
||||
|
||||
|
||||
$list['_agents_unknown_'] = $group_stat[0]["unknown"];
|
||||
$list['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"];
|
||||
|
||||
$list['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"];
|
||||
|
||||
$list['_monitors_ok_'] = $group_stat[0]["normal"];
|
||||
$list['_monitors_warning_'] = $group_stat[0]["warning"];
|
||||
$list['_monitors_critical_'] = $group_stat[0]["critical"];
|
||||
|
@ -311,19 +310,7 @@ function tactical_get_data ($id_user = false, $user_strict = false, $acltags, $r
|
|||
|
||||
}
|
||||
else {
|
||||
|
||||
if ($user_strict) {
|
||||
if (empty($acltags)) {
|
||||
$_tag_condition = '';
|
||||
}
|
||||
else {
|
||||
$_tag_condition = 'AND ' . tags_get_acl_tags_module_condition($acltags,'tae');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$_tag_condition = '';
|
||||
}
|
||||
|
||||
$_tag_condition = '';
|
||||
$result_list = db_get_all_rows_sql("SELECT COUNT(*) as contado, estado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
|
@ -370,7 +357,7 @@ function tactical_get_data ($id_user = false, $user_strict = false, $acltags, $r
|
|||
$list['_monitors_alerts_fired_'] = tactical_monitor_fired_alerts (explode(',',$user_groups_ids), $user_strict,explode(',',$user_groups_ids));
|
||||
$list['_monitors_alerts_'] = tactical_monitor_alerts (explode(',',$user_groups_ids), $user_strict,explode(',',$user_groups_ids));
|
||||
|
||||
$total_agentes = agents_get_agents (false, array('count(*) as total_agents'), 'AR',false, false, 1);
|
||||
$total_agentes = agents_get_agents (false, array('count(DISTINCT id_agente) as total_agents'), 'AR',false, false, 1);
|
||||
$list['_total_agents_'] = $total_agentes[0]['total_agents'];
|
||||
|
||||
$list["_monitor_checks_"] = $list["_monitors_not_init_"] + $list["_monitors_unknown_"] + $list["_monitors_warning_"] + $list["_monitors_critical_"] + $list["_monitors_ok_"];
|
||||
|
@ -379,109 +366,21 @@ function tactical_get_data ($id_user = false, $user_strict = false, $acltags, $r
|
|||
$list["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
||||
}
|
||||
|
||||
if ($user_strict) {
|
||||
$i = 1;
|
||||
$list = array();
|
||||
foreach ($user_tags as $group_id => $tag_name) {
|
||||
$id = db_get_value('id_tag', 'ttag', 'name', $tag_name);
|
||||
|
||||
$list[$i]['_id_'] = $id;
|
||||
$list[$i]['_name_'] = $tag_name;
|
||||
$list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;'));
|
||||
$list[$i]['_is_tag_'] = 1;
|
||||
|
||||
$list[$i]['_total_agents_'] = (int) tags_get_total_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_ok_'] = (int) tags_get_normal_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_warning_'] = (int) tags_get_warning_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_critical_'] = (int) tags_get_critical_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_unknown_'] = (int) tags_get_unknown_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_not_init_'] = (int) tags_get_not_init_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_monitors_ok_'] = (int) tags_get_normal_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_critical_'] = (int) tags_get_critical_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_warning_'] = (int) tags_get_warning_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_not_init_'] = (int) tags_get_not_init_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_unknown_'] = (int) tags_get_unknown_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags);
|
||||
|
||||
if (! defined ('METACONSOLE')) {
|
||||
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 {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
function tactical_status_modules_agents($id_user = false, $user_strict = false, $access = 'AR', $force_group_and_tag = true) {
|
||||
global $config;
|
||||
|
||||
|
||||
if ($id_user == false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
|
||||
$acltags = tags_get_user_groups_and_tags ($id_user, $access, $user_strict);
|
||||
|
||||
// If using metaconsole, the strict users will use the agent table of every node
|
||||
if (is_metaconsole() && $user_strict) {
|
||||
$servers = metaconsole_get_servers();
|
||||
|
||||
$result_list = array ();
|
||||
foreach ($servers as $server) {
|
||||
if (metaconsole_connect($server) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
$result_list = tactical_get_data ($id_user, $user_strict,
|
||||
$acltags);
|
||||
|
||||
if (!isset ($result_list[$server_item['_name_']])) {
|
||||
$result_list[$server_item['_name_']] = $server_item;
|
||||
}
|
||||
else {
|
||||
$result_list[$server_item['_name_']]['_monitors_ok_'] += $server_item['_monitors_ok_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_critical_'] += $server_item['_monitors_critical_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_warning_'] += $server_item['_monitors_warning_'];
|
||||
$result_list[$server_item['_name_']]['_agents_unknown_'] += $server_item['_agents_unknown_'];
|
||||
$result_list[$server_item['_name_']]['_total_agents_'] += $server_item['_total_agents_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_alerts_fired_'] += $server_item['_monitors_alerts_fired_'];
|
||||
|
||||
$result_list[$server_item['_name_']]['_agents_ok_'] += $server_item['_agents_ok_'];
|
||||
$result_list[$server_item['_name_']]['_agents_critical_'] += $server_item['_agents_critical_'];
|
||||
$result_list[$server_item['_name_']]['_agents_warning_'] += $server_item['_agents_warning_'];
|
||||
$result_list[$server_item['_name_']]['_monitors_alerts_'] += $server_item['_monitors_alerts_'];
|
||||
|
||||
$result_list[$server_item['_name_']]["_monitor_checks_"] += $server_item["_monitor_checks_"];
|
||||
$result_list[$server_item['_name_']]["_monitor_not_normal_"] += $server_item["_monitor_not_normal_"];
|
||||
$result_list[$server_item['_name_']]["_monitor_health_"] += $server_item["_monitor_health_"];
|
||||
$result_list[$server_item['_name_']]["_module_sanity_"] += $server_item["_module_sanity_"];
|
||||
$result_list[$server_item['_name_']]["_alerts_"] += $server_item["_alerts_"];
|
||||
$result_list[$server_item['_name_']]["_alert_level_"] += $server_item["_alert_level_"];
|
||||
$result_list[$server_item['_name_']]["_monitor_bad_"] += $server_item["_monitor_bad_"];
|
||||
$result_list[$server_item['_name_']]["_global_health_"] += $server_item["_global_health_"];
|
||||
$result_list[$server_item['_name_']]["_server_sanity_"] += $server_item["_server_sanity_"];
|
||||
$result_list[$server_item['_name_']]["_monitor_alerts_fire_count_"] += $server_item["_monitor_alerts_fire_count_"];
|
||||
$result_list[$server_item['_name_']]["_total_checks_"] += $server_item["_total_checks_"];
|
||||
$result_list[$server_item['_name_']]["_total_alerts_"] += $server_item["_total_alerts_"];
|
||||
}
|
||||
|
||||
}
|
||||
metaconsole_restore_db();
|
||||
return $result_list;
|
||||
}
|
||||
else {
|
||||
|
||||
$result_list = tactical_get_data ($id_user, $user_strict,
|
||||
$acltags);
|
||||
|
||||
return $result_list;
|
||||
}
|
||||
|
||||
$result_list = tactical_get_data ($id_user, $user_strict, $acltags);
|
||||
|
||||
return $result_list;
|
||||
}
|
||||
|
||||
function tactical_monitor_alerts ($group_array, $strict_user = false, $id_group_strict = false) {
|
||||
|
|
|
@ -479,7 +479,7 @@ else {
|
|||
'search' => $search_sql,
|
||||
'search_custom' => $search_sql_custom,
|
||||
'status' => $status),
|
||||
array ('COUNT(*) as total'), $access, false);
|
||||
array ('COUNT(DISTINCT id_agente) as total'), $access, false);
|
||||
$total_agents = isset ($total_agents[0]['total']) ?
|
||||
$total_agents[0]['total'] : 0;
|
||||
|
||||
|
|
|
@ -739,7 +739,7 @@ echo "</div>";
|
|||
$event_table = events_get_events_table($meta, $history);
|
||||
|
||||
if ($group_rep == 0) {
|
||||
$sql = "SELECT *, 1 event_rep
|
||||
$sql = "SELECT DISTINCT te.*, 1 event_rep
|
||||
FROM $event_table te LEFT JOIN tagent_secondary_group tasg
|
||||
ON te.id_agente = tasg.id_agent
|
||||
WHERE 1=1 " . $sql_post . "
|
||||
|
@ -808,7 +808,7 @@ if (($config['dbtype'] == 'oracle') && ($result !== false)) {
|
|||
}
|
||||
|
||||
if ($group_rep == 0) {
|
||||
$sql = "SELECT COUNT(id_evento)
|
||||
$sql = "SELECT COUNT(DISTINCT id_evento)
|
||||
FROM $event_table te
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON te.id_agente = tasg.id_agent
|
||||
|
|
Loading…
Reference in New Issue