mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
Fixed problems of count agents and modules in group view. Tiquet: #3028,#3297
This commit is contained in:
parent
4444433834
commit
b274ea805b
@ -14,8 +14,9 @@
|
|||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
include_once ("include/functions_groups.php");
|
|
||||||
include_once ("include/functions_tags.php");
|
include_once ($config['homedir'] . "/include/functions_groups.php");
|
||||||
|
include_once ($config['homedir'] . "/include/functions_tags.php");
|
||||||
|
|
||||||
function groupview_get_all_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $agent_filter = array(), $module_filter = array()) {
|
function groupview_get_all_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $agent_filter = array(), $module_filter = array()) {
|
||||||
global $config;
|
global $config;
|
||||||
@ -138,7 +139,7 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
|
||||||
// Calculate not_normal monitors
|
// Calculate not_normal monitors
|
||||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
|
||||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
||||||
|
|
||||||
@ -152,6 +153,8 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||||||
disabled
|
disabled
|
||||||
FROM tmetaconsole_agent
|
FROM tmetaconsole_agent
|
||||||
WHERE id_grupo = " . $group['id_grupo'] );
|
WHERE id_grupo = " . $group['id_grupo'] );
|
||||||
|
$list[$group['id_grupo']]['_agents_unknown_'] = 0;
|
||||||
|
$list[$group['id_grupo']]['_agents_not_init_'] = 0;
|
||||||
foreach ($agents as $agent) {
|
foreach ($agents as $agent) {
|
||||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
||||||
if ($agent['unknown_count'] > 0) {
|
if ($agent['unknown_count'] > 0) {
|
||||||
@ -235,55 +238,93 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach ($list_groups as $group) {
|
foreach ($list_groups as $group) {
|
||||||
$group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
//~ $group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
||||||
SUM(critical_count) AS _monitors_critical_,
|
//~ SUM(critical_count) AS _monitors_critical_,
|
||||||
SUM(normal_count) AS _monitors_ok_,
|
//~ SUM(normal_count) AS _monitors_ok_,
|
||||||
SUM(unknown_count) AS _monitors_unknown_,
|
//~ SUM(unknown_count) AS _monitors_unknown_,
|
||||||
SUM(notinit_count) AS _monitors_not_init_,
|
//~ SUM(notinit_count) AS _monitors_not_init_,
|
||||||
SUM(fired_count) AS _monitors_alerts_fired_,
|
//~ SUM(fired_count) AS _monitors_alerts_fired_,
|
||||||
COUNT(*) AS _total_agents_, id_grupo, intervalo,
|
//~ COUNT(*) AS _total_agents_, id_grupo, intervalo,
|
||||||
ultimo_contacto, disabled
|
//~ ultimo_contacto, disabled
|
||||||
FROM tagente WHERE id_grupo = " . $group['id_grupo'] . " AND disabled = 0 GROUP BY id_grupo");
|
//~ FROM tagente WHERE id_grupo = " . $group['id_grupo'] . " AND disabled = 0 GROUP BY id_grupo");
|
||||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
//~ $list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
||||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
//~ $list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
||||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
//~ $list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
||||||
$list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
//~ $list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
||||||
$list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
//~ $list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
||||||
|
$agent_not_init = agents_get_agents(array (
|
||||||
|
'disabled' => 0,
|
||||||
|
'id_grupo' => $group['id_grupo'],
|
||||||
|
'status' => AGENT_STATUS_NOT_INIT),
|
||||||
|
array ('COUNT(*) as total'), 'AR', 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'), 'AR', false);
|
||||||
|
$list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0;
|
||||||
|
$agent_total = agents_get_agents(array (
|
||||||
|
'disabled' => 0,
|
||||||
|
'id_grupo' => $group['id_grupo']),
|
||||||
|
array ('COUNT(*) as total'), 'AR', false);
|
||||||
|
$list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0;
|
||||||
|
//~
|
||||||
|
//~ $list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_'];
|
||||||
|
|
||||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_'];
|
//~ $list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
||||||
|
|
||||||
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
//~ $list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
|
||||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
//~ // Calculate not_normal monitors
|
||||||
|
//~ $list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
$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
|
||||||
|
AND ta.disabled = 0
|
||||||
|
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||||
|
INNER JOIN tagente_modulo tam
|
||||||
|
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||||
|
AND tam.disabled = 0
|
||||||
|
GROUP BY estado");
|
||||||
|
|
||||||
|
foreach ($result_list as $result) {
|
||||||
|
switch ($result['estado']) {
|
||||||
|
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||||
|
$list[$group['id_grupo']]['_monitors_critical_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_WARNING:
|
||||||
|
$list[$group['id_grupo']]['_monitors_warning_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||||
|
$list[$group['id_grupo']]['_monitors_unknown_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_NO_DATA:
|
||||||
|
case AGENT_MODULE_STATUS_NOT_INIT:
|
||||||
|
$list[$group['id_grupo']]['_monitors_not_init_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_NORMAL_ALERT:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_NORMAL:
|
||||||
|
$list[$group['id_grupo']]['_monitors_ok_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] +
|
||||||
|
$list[$group['id_grupo']]["_monitors_unknown_"] +
|
||||||
|
$list[$group['id_grupo']]["_monitors_warning_"] +
|
||||||
|
$list[$group['id_grupo']]["_monitors_critical_"] +
|
||||||
|
$list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
//~
|
||||||
// Calculate not_normal monitors
|
// Calculate not_normal monitors
|
||||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
$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,$group['id_grupo']);
|
||||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
|
||||||
|
|
||||||
if (($group['id_grupo'] != 0) && ($total_agents > 0)) {
|
|
||||||
$agents = db_get_all_rows_sql("SELECT warning_count,
|
|
||||||
critical_count,
|
|
||||||
normal_count,
|
|
||||||
unknown_count,
|
|
||||||
notinit_count,
|
|
||||||
fired_count,
|
|
||||||
disabled
|
|
||||||
FROM tagente
|
|
||||||
WHERE id_grupo = " . $group['id_grupo'] );
|
|
||||||
foreach ($agents as $agent) {
|
|
||||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
|
||||||
if ($agent['unknown_count'] > 0) {
|
|
||||||
$list[$group['id_grupo']]['_agents_unknown_'] += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0) && ($agent['unknown_count'] == 0)) {
|
|
||||||
if ($agent['notinit_count'] > 0) {
|
|
||||||
$list[$group['id_grupo']]['_agents_not_init_'] += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,12 +704,13 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||||||
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
||||||
|
|
||||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
$list[$group['id_grupo']]["_iconImg_"] = $group['icon'];
|
||||||
// Calculate not_normal monitors
|
// Calculate not_normal monitors
|
||||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
|
||||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
||||||
|
$list[$group['id_grupo']]['_agents_unknown_'] = 0;
|
||||||
|
$list[$group['id_grupo']]['_agents_not_init_'] = 0;
|
||||||
if (($group['id_grupo'] != 0) && ($total_agents > 0)) {
|
if (($group['id_grupo'] != 0) && ($total_agents > 0)) {
|
||||||
$agents = db_get_all_rows_sql("SELECT warning_count,
|
$agents = db_get_all_rows_sql("SELECT warning_count,
|
||||||
critical_count,
|
critical_count,
|
||||||
@ -679,6 +721,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||||||
disabled
|
disabled
|
||||||
FROM tmetaconsole_agent
|
FROM tmetaconsole_agent
|
||||||
WHERE id_grupo = " . $group['id_grupo'] );
|
WHERE id_grupo = " . $group['id_grupo'] );
|
||||||
|
|
||||||
foreach ($agents as $agent) {
|
foreach ($agents as $agent) {
|
||||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
||||||
if ($agent['unknown_count'] > 0) {
|
if ($agent['unknown_count'] > 0) {
|
||||||
@ -762,57 +805,118 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach ($list_groups as $group) {
|
foreach ($list_groups as $group) {
|
||||||
$group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
//~ $group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
||||||
SUM(critical_count) AS _monitors_critical_,
|
//~ SUM(critical_count) AS _monitors_critical_,
|
||||||
SUM(normal_count) AS _monitors_ok_,
|
//~ SUM(normal_count) AS _monitors_ok_,
|
||||||
SUM(unknown_count) AS _monitors_unknown_,
|
//~ SUM(unknown_count) AS _monitors_unknown_,
|
||||||
SUM(notinit_count) AS _monitors_not_init_,
|
//~ SUM(notinit_count) AS _monitors_not_init_,
|
||||||
SUM(fired_count) AS _monitors_alerts_fired_,
|
//~ SUM(fired_count) AS _monitors_alerts_fired_,
|
||||||
COUNT(*) AS _total_agents_, id_grupo, intervalo,
|
//~ COUNT(*) AS _total_agents_, id_grupo, intervalo,
|
||||||
ultimo_contacto, disabled
|
//~ ultimo_contacto, disabled
|
||||||
FROM tagente WHERE id_grupo = " . $group['id_grupo'] . " AND disabled = 0 GROUP BY id_grupo");
|
//~ FROM tagente WHERE id_grupo = " . $group['id_grupo'] . " AND disabled = 0 GROUP BY id_grupo");
|
||||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
//~ $list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
||||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
//~ $list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
||||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
//~ $list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
||||||
$list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
//~ $list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
||||||
$list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
//~ $list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
||||||
|
//~
|
||||||
|
//~ $list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_'];
|
||||||
|
//~
|
||||||
|
//~ $list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
||||||
|
//~
|
||||||
|
//~ $list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
//~
|
||||||
|
//~ // Calculate not_normal monitors
|
||||||
|
//~ $list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
//~
|
||||||
|
//~ $agent_not_init = agents_get_agents(array (
|
||||||
|
//~ 'disabled' => 0,
|
||||||
|
//~ 'id_grupo' => $group['id_grupo'],
|
||||||
|
//~ 'status' => AGENT_STATUS_NOT_INIT),
|
||||||
|
//~ array ('COUNT(*) as total'), 'AR', 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'), 'AR', false);
|
||||||
|
//~ $list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0;
|
||||||
|
$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
|
||||||
|
AND ta.disabled = 0
|
||||||
|
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||||
|
INNER JOIN tagente_modulo tam
|
||||||
|
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||||
|
AND tam.disabled = 0
|
||||||
|
GROUP BY estado");
|
||||||
|
|
||||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_'];
|
if ($result_list) {
|
||||||
|
foreach ($result_list as $result) {
|
||||||
|
switch ($result['estado']) {
|
||||||
|
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
|
||||||
|
|
||||||
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||||
|
$list[$group['id_grupo']]['_monitors_critical_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_WARNING:
|
||||||
|
$list[$group['id_grupo']]['_monitors_warning_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||||
|
$list[$group['id_grupo']]['_monitors_unknown_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_NO_DATA:
|
||||||
|
case AGENT_MODULE_STATUS_NOT_INIT:
|
||||||
|
$list[$group['id_grupo']]['_monitors_not_init_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_NORMAL_ALERT:
|
||||||
|
|
||||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_NORMAL:
|
||||||
|
$list[$group['id_grupo']]['_monitors_ok_'] += (int)$result['contado'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$agent_not_init = agents_get_agents(array (
|
||||||
|
'disabled' => 0,
|
||||||
|
'id_grupo' => $group['id_grupo'],
|
||||||
|
'status' => AGENT_STATUS_NOT_INIT),
|
||||||
|
array ('COUNT(*) as total'), 'AR', 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'), 'AR', false);
|
||||||
|
$list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0;
|
||||||
|
$agent_total = agents_get_agents(array (
|
||||||
|
'disabled' => 0,
|
||||||
|
'id_grupo' => $group['id_grupo']),
|
||||||
|
array ('COUNT(*) as total'), 'AR', false);
|
||||||
|
$list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0;
|
||||||
|
|
||||||
|
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] +
|
||||||
|
$list[$group['id_grupo']]["_monitors_unknown_"] +
|
||||||
|
$list[$group['id_grupo']]["_monitors_warning_"] +
|
||||||
|
$list[$group['id_grupo']]["_monitors_critical_"] +
|
||||||
|
$list[$group['id_grupo']]["_monitors_ok_"];
|
||||||
|
//~
|
||||||
// Calculate not_normal monitors
|
// Calculate not_normal monitors
|
||||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
$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,$group['id_grupo']);
|
||||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
}
|
||||||
|
else {
|
||||||
if (($group['id_grupo'] != 0) && ($total_agents > 0)) {
|
$list[$group['id_grupo']]['_agents_not_init_'] = 0;
|
||||||
$agents = db_get_all_rows_sql("SELECT warning_count,
|
$list[$group['id_grupo']]['_agents_unknown_'] = 0;
|
||||||
critical_count,
|
$list[$group['id_grupo']]['_total_agents_'] = 0;
|
||||||
normal_count,
|
$list[$group['id_grupo']]["_monitor_checks_"] = 0;
|
||||||
unknown_count,
|
$list[$group['id_grupo']]["_monitor_not_normal_"] = 0;
|
||||||
notinit_count,
|
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = 0;
|
||||||
fired_count,
|
|
||||||
disabled
|
|
||||||
FROM tagente
|
|
||||||
WHERE id_grupo = " . $group['id_grupo'] );
|
|
||||||
foreach ($agents as $agent) {
|
|
||||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
|
||||||
if ($agent['unknown_count'] > 0) {
|
|
||||||
$list[$group['id_grupo']]['_agents_unknown_'] += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0) && ($agent['unknown_count'] == 0)) {
|
|
||||||
if ($agent['notinit_count'] > 0) {
|
|
||||||
$list[$group['id_grupo']]['_agents_not_init_'] += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_strict) {
|
if ($user_strict) {
|
||||||
@ -873,6 +977,7 @@ function groupview_order_groups_for_parents ($view_groups) {
|
|||||||
}
|
}
|
||||||
// Build the group hierarchy
|
// Build the group hierarchy
|
||||||
foreach ($groups as $id => $group) {
|
foreach ($groups as $id => $group) {
|
||||||
|
$groups[$id]['have_parent'] = false;
|
||||||
if (!isset($groups[$id]['parent']))
|
if (!isset($groups[$id]['parent']))
|
||||||
continue;
|
continue;
|
||||||
$parent = $groups[$id]['parent'];
|
$parent = $groups[$id]['parent'];
|
||||||
|
@ -69,6 +69,16 @@ $strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_use
|
|||||||
|
|
||||||
$all_data = groupview_status_modules_agents ($config['id_user'], $strict_user, 'AR', $strict_user);
|
$all_data = groupview_status_modules_agents ($config['id_user'], $strict_user, 'AR', $strict_user);
|
||||||
|
|
||||||
|
$total_agentes = 0;
|
||||||
|
$monitor_ok = 0;
|
||||||
|
$monitor_warning = 0;
|
||||||
|
$monitor_critical = 0;
|
||||||
|
$monitor_unknown = 0;
|
||||||
|
$monitor_not_init = 0;
|
||||||
|
$agents_unknown = 0;
|
||||||
|
$agents_notinit = 0;
|
||||||
|
$all_alerts_fired = 0;
|
||||||
|
|
||||||
foreach ($all_data as $group_all_data) {
|
foreach ($all_data as $group_all_data) {
|
||||||
$total_agentes += $group_all_data["_total_agents_"];
|
$total_agentes += $group_all_data["_total_agents_"];
|
||||||
$monitor_ok += $group_all_data["_monitors_ok_"];
|
$monitor_ok += $group_all_data["_monitors_ok_"];
|
||||||
@ -79,7 +89,6 @@ foreach ($all_data as $group_all_data) {
|
|||||||
|
|
||||||
$agents_unknown += $group_all_data["_agents_unknown_"];
|
$agents_unknown += $group_all_data["_agents_unknown_"];
|
||||||
$agents_notinit += $group_all_data["_agents_not_init_"];
|
$agents_notinit += $group_all_data["_agents_not_init_"];
|
||||||
|
|
||||||
$all_alerts_fired += $group_all_data["_monitors_alerts_fired_"];
|
$all_alerts_fired += $group_all_data["_monitors_alerts_fired_"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +163,9 @@ if (!empty($result_groups)) {
|
|||||||
echo "<th width='10%' style='min-width: 60px;text-align:center;'>" . __("Critical") . "</th>";
|
echo "<th width='10%' style='min-width: 60px;text-align:center;'>" . __("Critical") . "</th>";
|
||||||
echo "<th width='10%' style='min-width: 60px;text-align:center;'>" . __("Alert fired") . "</th>";
|
echo "<th width='10%' style='min-width: 60px;text-align:center;'>" . __("Alert fired") . "</th>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
|
||||||
$result_groups = array_slice($result_groups, $offset, $config['block_size']);
|
$result_groups = array_slice($result_groups, $offset, $config['block_size']);
|
||||||
|
|
||||||
foreach ($result_groups as $data) {
|
foreach ($result_groups as $data) {
|
||||||
|
|
||||||
$groups_id = $data["_id_"];
|
$groups_id = $data["_id_"];
|
||||||
@ -243,7 +254,7 @@ if (!empty($result_groups)) {
|
|||||||
$agent_counter = agents_get_group_agents($groups_id);
|
$agent_counter = agents_get_group_agents($groups_id);
|
||||||
echo $link . count($agent_counter) . "</a>";
|
echo $link . count($agent_counter) . "</a>";
|
||||||
}
|
}
|
||||||
if ($data["_total_agents_"] > 0) {
|
if ($data["_total_agents_"] > 0 && $data["_id_"] != 0) {
|
||||||
echo $link . $data["_total_agents_"] . "</a>";
|
echo $link . $data["_total_agents_"] . "</a>";
|
||||||
}
|
}
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
@ -260,7 +271,7 @@ if (!empty($result_groups)) {
|
|||||||
if (($data["_id_"] == 0) && ($agents_unknown != 0)) {
|
if (($data["_id_"] == 0) && ($agents_unknown != 0)) {
|
||||||
echo $link . $agents_unknown . "</a>";
|
echo $link . $agents_unknown . "</a>";
|
||||||
}
|
}
|
||||||
if ($data["_agents_unknown_"] > 0) {
|
if ($data["_agents_unknown_"] > 0 && ($data["_id_"] != 0)) {
|
||||||
echo $link . $data["_agents_unknown_"] . "</a>";
|
echo $link . $data["_agents_unknown_"] . "</a>";
|
||||||
}
|
}
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
@ -277,7 +288,7 @@ if (!empty($result_groups)) {
|
|||||||
if (($data["_id_"] == 0) && ($agents_notinit != 0)) {
|
if (($data["_id_"] == 0) && ($agents_notinit != 0)) {
|
||||||
echo $link . $agents_notinit . "</a>";
|
echo $link . $agents_notinit . "</a>";
|
||||||
}
|
}
|
||||||
if ($data["_agents_not_init_"] > 0) {
|
if ($data["_agents_not_init_"] > 0 && ($data["_id_"] != 0)) {
|
||||||
echo $link . $data["_agents_not_init_"] . "</a>";
|
echo $link . $data["_agents_not_init_"] . "</a>";
|
||||||
}
|
}
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
@ -294,7 +305,7 @@ if (!empty($result_groups)) {
|
|||||||
if (($data["_id_"] == 0) && ($monitor_unknown != 0)) {
|
if (($data["_id_"] == 0) && ($monitor_unknown != 0)) {
|
||||||
echo $link . $monitor_unknown . "</a>";
|
echo $link . $monitor_unknown . "</a>";
|
||||||
}
|
}
|
||||||
if ($data["_monitors_unknown_"] > 0) {
|
if ($data["_monitors_unknown_"] > 0 && ($data["_id_"] != 0)) {
|
||||||
echo $link . $data["_monitors_unknown_"] . "</a>";
|
echo $link . $data["_monitors_unknown_"] . "</a>";
|
||||||
}
|
}
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
@ -311,7 +322,7 @@ if (!empty($result_groups)) {
|
|||||||
if (($data["_id_"] == 0) && ($monitor_not_init != 0)) {
|
if (($data["_id_"] == 0) && ($monitor_not_init != 0)) {
|
||||||
echo $link . $monitor_not_init . "</a>";
|
echo $link . $monitor_not_init . "</a>";
|
||||||
}
|
}
|
||||||
if ($data["_monitors_not_init_"] > 0) {
|
if ($data["_monitors_not_init_"] > 0 && ($data["_id_"] != 0)) {
|
||||||
echo $link . $data["_monitors_not_init_"] . "</a>";
|
echo $link . $data["_monitors_not_init_"] . "</a>";
|
||||||
}
|
}
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
@ -328,7 +339,7 @@ if (!empty($result_groups)) {
|
|||||||
if (($data["_id_"] == 0) && ($monitor_ok != 0)) {
|
if (($data["_id_"] == 0) && ($monitor_ok != 0)) {
|
||||||
echo $link . $monitor_ok . "</a>";
|
echo $link . $monitor_ok . "</a>";
|
||||||
}
|
}
|
||||||
if ($data["_monitors_ok_"] > 0) {
|
if ($data["_monitors_ok_"] > 0 && ($data["_id_"] != 0)) {
|
||||||
echo $link . $data["_monitors_ok_"] . "</a>";
|
echo $link . $data["_monitors_ok_"] . "</a>";
|
||||||
}
|
}
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
@ -345,7 +356,7 @@ if (!empty($result_groups)) {
|
|||||||
if (($data["_id_"] == 0) && ($monitor_warning != 0)) {
|
if (($data["_id_"] == 0) && ($monitor_warning != 0)) {
|
||||||
echo $link . $monitor_warning . "</a>";
|
echo $link . $monitor_warning . "</a>";
|
||||||
}
|
}
|
||||||
if ($data["_monitors_warning_"] > 0) {
|
if ($data["_monitors_warning_"] > 0 && ($data["_id_"] != 0)) {
|
||||||
echo $link . $data["_monitors_warning_"] . "</a>";
|
echo $link . $data["_monitors_warning_"] . "</a>";
|
||||||
}
|
}
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
@ -362,7 +373,7 @@ if (!empty($result_groups)) {
|
|||||||
if (($data["_id_"] == 0) && ($monitor_critical != 0)) {
|
if (($data["_id_"] == 0) && ($monitor_critical != 0)) {
|
||||||
echo $link . $monitor_critical . "</a>";
|
echo $link . $monitor_critical . "</a>";
|
||||||
}
|
}
|
||||||
if ($data["_monitors_critical_"] > 0) {
|
if ($data["_monitors_critical_"] > 0 && ($data["_id_"] != 0)) {
|
||||||
echo $link . $data["_monitors_critical_"] . "</a>";
|
echo $link . $data["_monitors_critical_"] . "</a>";
|
||||||
}
|
}
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
@ -379,7 +390,7 @@ if (!empty($result_groups)) {
|
|||||||
if (($data["_id_"] == 0) && ($all_alerts_fired != 0)) {
|
if (($data["_id_"] == 0) && ($all_alerts_fired != 0)) {
|
||||||
echo $link . $all_alerts_fired . "</a>";
|
echo $link . $all_alerts_fired . "</a>";
|
||||||
}
|
}
|
||||||
if ($data["_monitors_alerts_fired_"] > 0) {
|
if ($data["_monitors_alerts_fired_"] > 0 && ($data["_id_"] != 0)) {
|
||||||
echo $link . $data["_monitors_alerts_fired_"] . "</a>";
|
echo $link . $data["_monitors_alerts_fired_"] . "</a>";
|
||||||
}
|
}
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
|
@ -186,7 +186,8 @@ elseif ($status == AGENT_MODULE_STATUS_UNKNOWN) { //Unknown
|
|||||||
$sql_conditions .= " AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0";
|
$sql_conditions .= " AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0";
|
||||||
}
|
}
|
||||||
elseif ($status == AGENT_MODULE_STATUS_NOT_INIT) { //Not init
|
elseif ($status == AGENT_MODULE_STATUS_NOT_INIT) { //Not init
|
||||||
$sql_conditions .= " AND tagente_estado.utimestamp = 0
|
$sql_conditions .= " AND tagente_estado.utimestamp = 0 AND
|
||||||
|
tagente_estado.estado IN (".AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT." )
|
||||||
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)";
|
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user