[Secondary Groups] Added secondary agents to node group view
This commit is contained in:
parent
a724851a4d
commit
3463cd1ea2
|
@ -503,7 +503,10 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
AND (
|
||||
id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
OR id_grupo IN (SELECT id_group FROM tagent_secondary_group WHERE id_group IN (" . $user_groups_ids . "))
|
||||
)
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
break;
|
||||
case "postgresql":
|
||||
|
@ -529,7 +532,11 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
//Add the group "All" at first
|
||||
$group_all = array('id_grupo'=>0, 'nombre'=>'All', 'icon'=>'', 'parent'=>'', 'propagate'=>0, 'disabled'=>0,
|
||||
'custom_id'=>'', 'id_skin'=>0, 'description'=>'', 'contact'=>'', 'other'=>'', 'password'=>'');
|
||||
array_unshift($list_groups, $group_all);
|
||||
if ($list_groups !== false) {
|
||||
array_unshift($list_groups, $group_all);
|
||||
} else {
|
||||
$list_groups = array($group_all);
|
||||
}
|
||||
|
||||
if (!$user_strict) {
|
||||
//Takes the parents even without agents, first ids
|
||||
|
@ -746,6 +753,10 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
}
|
||||
else {
|
||||
foreach ($list_groups as $group) {
|
||||
// If id group is 0 get all accesses groups
|
||||
$group_id = $group['id_grupo'] == 0
|
||||
? $user_groups_ids
|
||||
: $group['id_grupo'];
|
||||
$agent_not_init = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
|
@ -765,9 +776,9 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
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(DISTINCT id_agente) as total'), $access, false);
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo']),
|
||||
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_"];
|
||||
|
@ -776,11 +787,16 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = ta.id_agente
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp > 0
|
||||
AND (
|
||||
ta.id_grupo IN (" . $group_id . ")
|
||||
OR tasg.id_group IN (" . $group_id . ")
|
||||
)
|
||||
GROUP BY estado");
|
||||
if ($result_list) {
|
||||
foreach ($result_list as $result) {
|
||||
|
@ -804,12 +820,17 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = ta.id_agente
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.estado = 0
|
||||
AND (tae.utimestamp > 0 OR tam.id_tipo_modulo IN(21,22,23,100))
|
||||
AND (tae.utimestamp > 0 OR tam.id_tipo_modulo IN(21,22,23,100))
|
||||
AND (
|
||||
ta.id_grupo IN (" . $group_id . ")
|
||||
OR tasg.id_group IN (" . $group_id . ")
|
||||
)
|
||||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = isset ($result_normal['contado']) ? $result_normal['contado'] : 0;
|
||||
|
||||
|
@ -817,53 +838,23 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = ta.id_agente
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp = 0 AND
|
||||
tae.estado IN (".AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT." )
|
||||
AND tam.id_tipo_modulo NOT IN (21,22,23,100)
|
||||
AND (
|
||||
ta.id_grupo IN (" . $group_id . ")
|
||||
OR tasg.id_group IN (" . $group_id . ")
|
||||
)
|
||||
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_not_init_'] = (int) tags_get_not_init_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]['_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;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,9 +69,7 @@ else {
|
|||
// Header
|
||||
ui_print_page_header (__("Group view"), "images/group.png", false, "", false, $updated_time);
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
$all_data = groupview_status_modules_agents ($config['id_user'], $strict_user, ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'), $strict_user);
|
||||
$strict_user = false;
|
||||
|
||||
$total_agentes = 0;
|
||||
$monitor_ok = 0;
|
||||
|
@ -84,33 +82,53 @@ $agents_critical = 0;
|
|||
$agents_notinit = 0;
|
||||
$all_alerts_fired = 0;
|
||||
|
||||
foreach ($all_data as $group_all_data) {
|
||||
$total_agentes += $group_all_data["_total_agents_"];
|
||||
$monitor_ok += $group_all_data["_monitors_ok_"];
|
||||
$monitor_warning += $group_all_data["_monitors_warning_"];
|
||||
$monitor_critical += $group_all_data["_monitors_critical_"];
|
||||
$monitor_unknown += $group_all_data["_monitors_unknown_"];
|
||||
$monitor_not_init += $group_all_data["_monitors_not_init_"];
|
||||
|
||||
$agents_unknown += $group_all_data["_agents_unknown_"];
|
||||
$agents_notinit += $group_all_data["_agents_not_init_"];
|
||||
$agents_critical += $group_all_data["_agents_critical_"];
|
||||
//Groups and tags
|
||||
$result_groups = groupview_get_groups_list($config['id_user'], $strict_user,
|
||||
($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'), true, true);
|
||||
$count = count($result_groups);
|
||||
|
||||
$all_alerts_fired += $group_all_data["_monitors_alerts_fired_"];
|
||||
if ($result_groups[0]["_id_"] == 0) {
|
||||
$total_agentes = $result_groups[0]["_total_agents_"];
|
||||
$monitor_ok = $result_groups[0]["_monitors_ok_"];
|
||||
$monitor_warning = $result_groups[0]["_monitors_warning_"];
|
||||
$monitor_critical = $result_groups[0]["_monitors_critical_"];
|
||||
$monitor_unknown = $result_groups[0]["_monitors_unknown_"];
|
||||
$monitor_not_init = $result_groups[0]["_monitors_not_init_"];
|
||||
|
||||
$agents_unknown = $result_groups[0]["_agents_unknown_"];
|
||||
$agents_notinit = $result_groups[0]["_agents_not_init_"];
|
||||
$agents_critical = $result_groups[0]["_agents_critical_"];
|
||||
|
||||
$all_alerts_fired = $result_groups[0]["_monitors_alerts_fired_"];
|
||||
}
|
||||
|
||||
$total = $monitor_ok + $monitor_warning + $monitor_critical + $monitor_unknown + $monitor_not_init;
|
||||
|
||||
//Monitors
|
||||
$total_ok = format_numeric (($monitor_ok*100)/$total,2);
|
||||
$total_warning = format_numeric (($monitor_warning*100)/$total,2);
|
||||
$total_critical = format_numeric (($monitor_critical*100)/$total,2);
|
||||
$total_unknown = format_numeric (($monitor_unknown*100)/$total,2);
|
||||
$total_monitor_not_init = format_numeric (($monitor_not_init*100)/$total,2);
|
||||
//Modules
|
||||
$total_ok =0;
|
||||
$total_warning =0;
|
||||
$total_critical =0;
|
||||
$total_unknown =0;
|
||||
$total_monitor_not_init =0;
|
||||
//Agents
|
||||
$total_agent_unknown = format_numeric (($agents_unknown*100)/$total_agentes,2);
|
||||
$total_agent_critical = format_numeric (($agents_critical*100)/$total_agentes,2);
|
||||
$total_not_init = format_numeric (($agents_notinit*100)/$total_agentes,2);
|
||||
$total_agent_unknown = 0;
|
||||
$total_agent_critical = 0;
|
||||
$total_not_init = 0;
|
||||
|
||||
if ($total > 0) {
|
||||
//Modules
|
||||
$total_ok = format_numeric (($monitor_ok*100)/$total,2);
|
||||
$total_warning = format_numeric (($monitor_warning*100)/$total,2);
|
||||
$total_critical = format_numeric (($monitor_critical*100)/$total,2);
|
||||
$total_unknown = format_numeric (($monitor_unknown*100)/$total,2);
|
||||
$total_monitor_not_init = format_numeric (($monitor_not_init*100)/$total,2);
|
||||
}
|
||||
if ($total_agentes > 0) {
|
||||
//Agents
|
||||
$total_agent_unknown = format_numeric (($agents_unknown*100)/$total_agentes,2);
|
||||
$total_agent_critical = format_numeric (($agents_critical*100)/$total_agentes,2);
|
||||
$total_not_init = format_numeric (($agents_notinit*100)/$total_agentes,2);
|
||||
}
|
||||
|
||||
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="databox">';
|
||||
echo "<tr>";
|
||||
|
@ -136,12 +154,6 @@ echo '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="data
|
|||
echo "</tr>";
|
||||
echo "</table>";
|
||||
|
||||
//Groups and tags
|
||||
$result_groups = groupview_get_groups_list($config['id_user'], $strict_user,
|
||||
($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'), true, true);
|
||||
|
||||
$count = count($result_groups);
|
||||
|
||||
if ($count == 1) {
|
||||
if ($result_groups[0]['_id_'] == 0) {
|
||||
unset($result_groups[0]);
|
||||
|
|
Loading…
Reference in New Issue