From 2bf3887bd719fda72074e2091c66f0e730c3a416 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 19 Feb 2015 19:09:36 +0100 Subject: [PATCH] A lot of ACL fixes --- pandora_console/include/class/Tree.class.php | 14 +- pandora_console/include/functions_groups.php | 287 ++++---- pandora_console/include/functions_tags.php | 670 +++++++++--------- .../operation/agentes/tactical.php | 115 ++- 4 files changed, 566 insertions(+), 520 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index d7b8e83355..0c6a90533a 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -329,8 +329,10 @@ class Tree { $groups[] = $group_id; } if (!empty($groups)) { - $user_groups_str = implode(",", $groups); - $group_acl = "AND ta.id_grupo IN ($user_groups_str)"; + if (array_search(0, $groups) === false) { + $user_groups_str = implode(",", $groups); + $group_acl = " AND ta.id_grupo IN ($user_groups_str) "; + } } else { $group_acl = "AND ta.id_grupo = -1"; @@ -455,8 +457,10 @@ class Tree { } } if (!empty($groups)) { - $user_groups_str = implode(",", $groups); - $group_acl = " AND ta.id_grupo IN ($user_groups_str) "; + if (array_search(0, $groups) === false) { + $user_groups_str = implode(",", $groups); + $group_acl = " AND ta.id_grupo IN ($user_groups_str) "; + } } else { $group_acl = "AND ta.id_grupo = -1"; @@ -912,12 +916,10 @@ class Tree { protected function getItems ($item_for_count = false) { $sql = $this->getSql($item_for_count); - if (empty($sql)) return array(); $data = db_process_sql($sql); - if (empty($data)) return array(); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 8dd9df3946..77b74e3c83 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1360,179 +1360,106 @@ function groups_agent_warning ($group_array, $strict_user = false, $id_group_str } -// Get monitor NOT INIT, except disabled AND async modules - -function groups_monitor_not_init ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_monitors_count ($type, $group_array, $strict_user = false, $id_group_strict = false) { // If there are not groups to query, we jump to nextone - if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)) { $group_array = array($group_array); } $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; + $group_clause = "($group_clause)"; - if ($strict_user) { - - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 5 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + switch ($type) { + case AGENT_MODULE_STATUS_CRITICAL_ALERT: + case AGENT_MODULE_STATUS_CRITICAL_BAD: + if ($strict_user) + $status = AGENT_MODULE_STATUS_CRITICAL_ALERT.",".AGENT_MODULE_STATUS_CRITICAL_BAD; + else + $status = 'critical_count'; + break; + case AGENT_MODULE_STATUS_WARNING_ALERT: + case AGENT_MODULE_STATUS_WARNING: + if ($strict_user) + $status = AGENT_MODULE_STATUS_WARNING_ALERT.",".AGENT_MODULE_STATUS_WARNING; + else + $status = 'warning_count'; + break; + case AGENT_MODULE_STATUS_UNKNOWN: + if ($strict_user) + $status = AGENT_MODULE_STATUS_UNKNOWN; + else + $status = 'unknown_count'; + break; + case AGENT_MODULE_STATUS_NO_DATA: + case AGENT_MODULE_STATUS_NOT_INIT: + if ($strict_user) + $status = AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT; + else + $status = 'notinit_count'; + break; + case AGENT_MODULE_STATUS_NORMAL_ALERT: + case AGENT_MODULE_STATUS_NORMAL: + if ($strict_user) + $status = AGENT_MODULE_STATUS_NORMAL_ALERT.",".AGENT_MODULE_STATUS_NORMAL; + else + $status = 'normal_count'; + break; + default: + // The type doesn't exist + return; } - return $count > 0 ? $count : 0; + if ($strict_user) { + $sql = "SELECT COUNT(DISTINCT tam.id_agente_modulo) + FROM tagente_modulo AS tam + INNER JOIN tagente_estado AS tae + ON tam.id_agente_modulo = tae.id_agente_modulo + AND tae.estado IN ($status) + INNER JOIN tagente AS ta + ON tam.id_agente = ta.id_agente + AND ta.disabled = 0 + AND ta.id_grupo = $id_group_strict + WHERE tam.disabled = 0"; + } + else { + $sql = "SELECT SUM($status) + FROM tagente + WHERE disabled = 0 + AND id_grupo IN $group_clause"; + } + + $count = (int) db_get_sql ($sql); + + return $count; +} + +// Get monitor NOT INIT, except disabled AND async modules +function groups_monitor_not_init ($group_array, $strict_user = false, $id_group_strict = false) { + return groups_monitors_count (AGENT_MODULE_STATUS_NOT_INIT, $group_array, $strict_user, $id_group_strict); } // Get monitor OK, except disabled and non-init - function groups_monitor_ok ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - - if ($strict_user) { - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 0 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; + return groups_monitors_count (AGENT_MODULE_STATUS_NORMAL, $group_array, $strict_user, $id_group_strict); } // Get monitor CRITICAL, except disabled and non-init - function groups_monitor_critical ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - - if ($strict_user) { - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 1 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; + return groups_monitors_count (AGENT_MODULE_STATUS_CRITICAL_BAD, $group_array, $strict_user, $id_group_strict); } // Get monitor WARNING, except disabled and non-init - function groups_monitor_warning ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - if ($strict_user) { - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 2 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; + return groups_monitors_count (AGENT_MODULE_STATUS_WARNING, $group_array, $strict_user, $id_group_strict); } // Get monitor UNKNOWN, except disabled and non-init - function groups_monitor_unknown ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - if ($strict_user) { - - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 3 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; + return groups_monitors_count (AGENT_MODULE_STATUS_UNKNOWN, $group_array, $strict_user, $id_group_strict); } // Get alerts defined for a given group, except disabled @@ -1553,15 +1480,13 @@ function groups_monitor_alerts ($group_array, $strict_user = false, $id_group_st $group_clause = "(" . $group_clause . ")"; if ($strict_user) { - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $sql = "SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente WHERE tagente.id_grupo = $id_group_strict AND tagente_modulo.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - $tags_clause"; + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"; $count = db_get_sql ($sql); return $count; } else { @@ -1594,8 +1519,6 @@ function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_gr $group_clause = "(" . $group_clause . ")"; if ($strict_user) { - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - $sql = "SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente WHERE tagente.id_grupo = $id_group_strict AND tagente_modulo.id_agente = tagente.id_agente @@ -1603,7 +1526,7 @@ function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_gr AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND talert_template_modules.disabled = 0 AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - AND times_fired > 0 ".$tags_clause; + AND times_fired > 0 "; $count = db_get_sql ($sql); return $count; @@ -1983,7 +1906,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu // Calculate not_normal monitors $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]["_monitor_not_normal_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { $list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); } else { @@ -2089,7 +2012,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu // Calculate not_normal monitors $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]["_monitor_not_normal_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { $list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); } else { @@ -2171,20 +2094,67 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $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_'] = tags_total_agents ($id, $acltags); + $list[$i]['_total_agents_'] = tags_get_total_agents ($id, $acltags); $list[$i]['_agents_unknown_'] = tags_get_unknown_agents ($id, $acltags); - $list[$i]['_monitors_ok_'] = tags_monitors_ok ($id, $acltags); + $list[$i]['_agents_not_init_'] = tags_get_not_init_agents ($id, $acltags); + $list[$i]['_monitors_ok_'] = tags_monitors_normal ($id, $acltags); $list[$i]['_monitors_critical_'] = tags_monitors_critical ($id, $acltags); $list[$i]['_monitors_warning_'] = tags_monitors_warning ($id, $acltags); + $list[$i]['_monitors_not_init_'] = tags_monitors_not_init ($id, $acltags); + $list[$i]['_monitors_unknown_'] = tags_monitors_unknown ($id, $acltags); $list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags); if ($mode == 'tactical' || $mode == 'tree') { - $list[$i]['_agents_ok_'] = tags_agent_ok ($id, $acltags); - $list[$i]['_agents_warning_'] = tags_agent_warning ($id, $acltags); + $list[$i]['_agents_ok_'] = tags_get_normal_agents ($id, $acltags); + $list[$i]['_agents_warning_'] = tags_get_warning_agents ($id, $acltags); $list[$i]['_agents_critical_'] = tags_get_critical_agents ($id, $acltags); $list[$i]['_monitors_alerts_'] = tags_get_monitors_alerts ($id, $acltags); } - + if ($mode == 'tactical') { + // 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_"]; + + // Calculate not_normal monitors + $list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"]; + + if ($list[$i]["_monitor_not_normal_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_monitor_health_"] = 100; + } + + 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); + } + else { + $list[$i]["_module_sanity_"] = 100; + } + + if (isset($list[$i]["_monitors_alerts_"])) { + if ($list[$i]["_monitors_alerts_fired_"] > 0 && $list[$i]["_monitors_alerts_"] > 0) { + $list[$i]["_alert_level_"] = format_numeric (100 - ($list[$i]["_monitors_alerts_fired_"] / ($list[$i]["_monitors_alerts_"] / 100)), 1); + } + else { + $list[$i]["_alert_level_"] = 100; + } + } + else { + $list[$i]["_alert_level_"] = 100; + $list[$i]["_monitors_alerts_"] = 0; + } + + $list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"]; + + 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); + } + else { + $list[$i]["_global_health_"] = 100; + } + + $list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1); + } if ($returnAllGroup) { $list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_']; @@ -2194,7 +2164,8 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_']; $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; - $list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_']; + $list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_']; + $list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_']; if ($mode == 'tactical' || $mode == 'tree') { $list[0]['_agents_ok_'] += $list[$i]['_agents_ok_']; diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index bd1f69a121..ce6877e4ef 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -19,144 +19,6 @@ * @subpackage TAGS */ - /** - * Get critical agents by using the status code in modules by filtering by id_tag. - * - * @param int $id_tag Id of the tag to search module with critical state - * - * @return mixed Returns count of agents in critical status or false if they aren't. - */ -function tags_agent_critical ($id_tag) { - - return db_get_sql ("SELECT COUNT(*) - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente.disabled=0 - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = $id_tag - AND critical_count>0"); -} - - /** - * Get unknown agents by using the status code in modules by filtering by id_tag. - * - * @param int $id_tag Id of the tag to search module with unknown state - * - * @return mixed Returns count of agents in unknown status or false if they aren't. - */ -function tags_agent_unknown ($id_tag) { - - return db_get_sql ("SELECT COUNT(*) - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente.disabled=0 - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = $id_tag - AND critical_count=0 AND warning_count=0 AND unknown_count>0"); -} - -/** - * Get total agents filtering by id_tag. - * - * @param int $id_tag Id of the tag to search total agents - * - * @return mixed Returns count of agents with this tag or false if they aren't. - */ -function tags_total_agents ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; - } - - $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = " . $id_tag . - $groups_clause; - - return db_get_sql ($total_agents); -} - - /** - * Get normal agents by using the status code in modules by filtering by id_tag. - * - * @param int $id_tag Id of the tag to search module with normal state - * - * @return mixed Returns count of agents in normal status or false if they aren't. - */ -function tags_agent_ok ($id_tag, $groups_and_tags = array()) { - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; - } - - return db_get_sql ("SELECT COUNT(*) - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente.disabled=0 - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = $id_tag - AND normal_count=total_count - $groups_clause"); -} - - /** - * Get warning agents by using the status code in modules by filtering by id_tag. - * - * @param int $id_tag Id of the tag to search module with warning state - * - * @return mixed Returns count of agents in warning status or false if they aren't. - */ -function tags_agent_warning ($id_tag, $groups_and_tags = array()) { - - return db_get_sql ("SELECT COUNT(*) - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente.disabled=0 - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = $id_tag - AND critical_count=0 AND warning_count>0"); -} - /** * Find a tag searching by tag's or description name. * @@ -1430,6 +1292,196 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c return false; } +/** + * Get total agents filtering by id_tag. + * + * @param int $id_tag Id of the tag to search total agents + * + * @return mixed Returns count of agents with this tag or false if they aren't. + */ +function tags_get_total_agents ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + + $groups_id = array(); + foreach ($groups_and_tags as $group_id => $tags) { + if (!empty($tags)) { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) + $groups_id[] = $group_id; + } + } + } + if (array_search(0, $groups_id) === false) { + $groups_id_str = implode(",", $groups_id); + $groups_clause = " AND ta.id_grupo IN ($groups_id_str)"; + } + } + + $total_agents = "SELECT COUNT(DISTINCT ta.id_agente) + FROM tagente AS ta + INNER JOIN tagente_modulo AS tam + ON ta.id_agente = tam.id_agente + AND tam.disabled = 0 + INNER JOIN ttag_module AS ttm + ON ttm.id_tag = $id_tag + AND tam.id_agente_modulo = ttm.id_agente_modulo + WHERE ta.disabled = 0 + $groups_clause"; + + return db_get_sql($total_agents); +} + + /** + * Get normal agents by using the status code in modules by filtering by id_tag. + * + * @param int $id_tag Id of the tag to search module with normal state + * + * @return mixed Returns count of agents in normal status or false if they aren't. + */ +function tags_get_normal_agents ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + + $groups_id = array(); + foreach ($groups_and_tags as $group_id => $tags) { + if (!empty($tags)) { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) + $groups_id[] = $group_id; + } + } + } + if (array_search(0, $groups_id) === false) { + $groups_id_str = implode(",", $groups_id); + $groups_clause = " AND ta.id_grupo IN ($groups_id_str)"; + } + } + + $ok_agents = "SELECT COUNT(DISTINCT ta.id_agente) + FROM tagente AS ta + INNER JOIN tagente_modulo AS tam + ON ta.id_agente = tam.id_agente + AND tam.disabled = 0 + INNER JOIN ttag_module AS ttm + ON ttm.id_tag = $id_tag + AND tam.id_agente_modulo = ttm.id_agente_modulo + WHERE ta.disabled = 0 + AND ta.total_count > 0 + AND ta.normal_count = ta.total_count + $groups_clause"; + + return db_get_sql($ok_agents); +} + + /** + * Get warning agents by using the status code in modules by filtering by id_tag. + * + * @param int $id_tag Id of the tag to search module with warning state + * + * @return mixed Returns count of agents in warning status or false if they aren't. + */ +function tags_get_warning_agents ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + + $groups_id = array(); + foreach ($groups_and_tags as $group_id => $tags) { + if (!empty($tags)) { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) + $groups_id[] = $group_id; + } + } + } + if (array_search(0, $groups_id) === false) { + $groups_id_str = implode(",", $groups_id); + $groups_clause = " AND ta.id_grupo IN ($groups_id_str)"; + } + } + + $warning_agents = "SELECT COUNT(DISTINCT ta.id_agente) + FROM tagente AS ta + INNER JOIN tagente_modulo AS tam + ON ta.id_agente = tam.id_agente + AND tam.disabled = 0 + INNER JOIN ttag_module AS ttm + ON ttm.id_tag = $id_tag + AND tam.id_agente_modulo = ttm.id_agente_modulo + WHERE ta.disabled = 0 + AND ta.total_count > 0 + AND ta.critical_count = 0 + AND ta.warning_count > 0 + $groups_clause"; + + return db_get_sql($warning_agents); +} + +/** + * Get unknown agents filtering by id_tag. + * + * @param int $id_tag Id of the tag to search unknown agents + * + * @return mixed Returns count of unknown agents with this tag or false if they aren't. + */ +function tags_get_critical_agents ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + + $groups_id = array(); + foreach ($groups_and_tags as $group_id => $tags) { + if (!empty($tags)) { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) + $groups_id[] = $group_id; + } + } + } + if (array_search(0, $groups_id) === false) { + $groups_id_str = implode(",", $groups_id); + $groups_clause = " AND ta.id_grupo IN ($groups_id_str)"; + } + } + + $critical_agents = "SELECT COUNT(DISTINCT ta.id_agente) + FROM tagente AS ta + INNER JOIN tagente_modulo AS tam + ON ta.id_agente = tam.id_agente + AND tam.disabled = 0 + INNER JOIN ttag_module AS ttm + ON ttm.id_tag = $id_tag + AND tam.id_agente_modulo = ttm.id_agente_modulo + WHERE ta.disabled = 0 + AND ta.critical_count > 0 + $groups_clause"; + + return db_get_sql($critical_agents); +} + /** * Get unknown agents filtering by id_tag. * @@ -1445,159 +1497,174 @@ function tags_get_unknown_agents ($id_tag, $groups_and_tags = array()) { $groups_clause = ""; if (!empty($groups_and_tags)) { - $i = 0; + + $groups_id = array(); foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { + if (!empty($tags)) { $tags_arr = explode(',', $tags); foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } + if ($tag == $id_tag) + $groups_id[] = $group_id; } } } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; + if (array_search(0, $groups_id) === false) { + $groups_id_str = implode(",", $groups_id); + $groups_clause = " AND ta.id_grupo IN ($groups_id_str)"; + } } - $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = " . $id_tag . " - AND tagente.critical_count=0 - AND tagente.warning_count=0 - AND tagente.unknown_count>0 - $groups_clause"; + $unknown_agents = "SELECT COUNT(DISTINCT ta.id_agente) + FROM tagente AS ta + INNER JOIN tagente_modulo AS tam + ON ta.id_agente = tam.id_agente + AND tam.disabled = 0 + INNER JOIN ttag_module AS ttm + ON ttm.id_tag = $id_tag + AND tam.id_agente_modulo = ttm.id_agente_modulo + WHERE ta.disabled = 0 + AND ta.critical_count = 0 + AND ta.warning_count = 0 + AND ta.unknown_count > 0 + $groups_clause"; - return db_get_sql ($total_agents); + return db_get_sql($unknown_agents); } -function tags_monitors_ok ($id_tag, $groups_and_tags = array()) { +/** + * Get not init agents filtering by id_tag. + * + * @param int $id_tag Id of the tag to search not init agents + * + * @return mixed Returns count of not init agents with this tag or false if they aren't. + */ +function tags_get_not_init_agents ($id_tag, $groups_and_tags = array()) { // Avoid mysql error if (empty($id_tag)) return; - + $groups_clause = ""; if (!empty($groups_and_tags)) { - $i = 0; + + $groups_id = array(); foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { + if (!empty($tags)) { $tags_arr = explode(',', $tags); foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } + if ($tag == $id_tag) + $groups_id[] = $group_id; } } } - $groups_clause = " AND id_grupo IN ($groups_id)"; + if (array_search(0, $groups_id) === false) { + $groups_id_str = implode(",", $groups_id); + $groups_clause = " AND ta.id_grupo IN ($groups_id_str)"; + } } - - $sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 0 - AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente - WHERE disabled = 0 - $groups_clause) - AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag = " . $id_tag .")"; + + $not_init_agents = "SELECT COUNT(DISTINCT ta.id_agente) + FROM tagente AS ta + INNER JOIN tagente_modulo AS tam + ON ta.id_agente = tam.id_agente + AND tam.disabled = 0 + INNER JOIN ttag_module AS ttm + ON ttm.id_tag = $id_tag + AND tam.id_agente_modulo = ttm.id_agente_modulo + WHERE ta.disabled = 0 + AND ta.total_count = ta.notinit_count + $groups_clause"; + + return db_get_sql($not_init_agents); +} + +function tags_monitors_count ($type, $id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + + $groups_id = array(); + foreach ($groups_and_tags as $group_id => $tags) { + if (!empty($tags)) { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) + $groups_id[] = $group_id; + } + } + } + if (array_search(0, $groups_id) === false) { + $groups_id_str = implode(",", $groups_id); + $groups_clause = " AND ta.id_grupo IN ($groups_id_str)"; + } + } + + switch ($type) { + case AGENT_MODULE_STATUS_CRITICAL_ALERT: + case AGENT_MODULE_STATUS_CRITICAL_BAD: + $status = AGENT_MODULE_STATUS_CRITICAL_ALERT.",".AGENT_MODULE_STATUS_CRITICAL_BAD; + break; + case AGENT_MODULE_STATUS_WARNING_ALERT: + case AGENT_MODULE_STATUS_WARNING: + $status = AGENT_MODULE_STATUS_WARNING_ALERT.",".AGENT_MODULE_STATUS_WARNING; + break; + case AGENT_MODULE_STATUS_UNKNOWN: + $status = AGENT_MODULE_STATUS_UNKNOWN; + break; + case AGENT_MODULE_STATUS_NO_DATA: + case AGENT_MODULE_STATUS_NOT_INIT: + $status = AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT; + break; + case AGENT_MODULE_STATUS_NORMAL_ALERT: + case AGENT_MODULE_STATUS_NORMAL: + $status = AGENT_MODULE_STATUS_NORMAL_ALERT.",".AGENT_MODULE_STATUS_NORMAL; + break; + default: + // The type doesn't exist + return; + } + + $sql = "SELECT COUNT(DISTINCT tam.id_agente_modulo) + FROM tagente_modulo AS tam + INNER JOIN tagente_estado AS tae + ON tam.id_agente_modulo = tae.id_agente_modulo + AND tae.estado IN ($status) + INNER JOIN ttag_module AS ttm + ON ttm.id_tag = $id_tag + AND tam.id_agente_modulo = ttm.id_agente_modulo + INNER JOIN tagente AS ta + ON tam.id_agente = ta.id_agente + AND ta.disabled = 0 + $groups_clause + WHERE tam.disabled = 0"; $count = db_get_sql ($sql); return $count; } +function tags_monitors_normal ($id_tag, $groups_and_tags = array()) { + return tags_monitors_count(AGENT_MODULE_STATUS_NORMAL, $id_tag, $groups_and_tags); +} + function tags_monitors_critical ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND id_grupo IN ($groups_id)"; - } - - $sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 1 - AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente - WHERE disabled = 0 - $groups_clause) - AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag = " . $id_tag .")"; - - $count = db_get_sql ($sql); - - return $count; + return tags_monitors_count(AGENT_MODULE_STATUS_CRITICAL_BAD, $id_tag, $groups_and_tags); } function tags_monitors_warning ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND id_grupo IN ($groups_id)"; - } - - $sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 2 - AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente - WHERE disabled = 0 - $groups_clause) - AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag = " . $id_tag .")"; - - $count = db_get_sql ($sql); - - return $count; + return tags_monitors_count(AGENT_MODULE_STATUS_WARNING, $id_tag, $groups_and_tags); +} + +function tags_monitors_not_init ($id_tag, $groups_and_tags = array()) { + return tags_monitors_count(AGENT_MODULE_STATUS_NOT_INIT, $id_tag, $groups_and_tags); +} + +function tags_monitors_unknown ($id_tag, $groups_and_tags = array()) { + return tags_monitors_count(AGENT_MODULE_STATUS_UNKNOWN, $id_tag, $groups_and_tags); } function tags_monitors_fired_alerts ($id_tag, $groups_and_tags = array()) { @@ -1605,26 +1672,24 @@ function tags_monitors_fired_alerts ($id_tag, $groups_and_tags = array()) { // Avoid mysql error if (empty($id_tag)) return; - + $groups_clause = ""; if (!empty($groups_and_tags)) { - $i = 0; + + $groups_id = array(); foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { + if (!empty($tags)) { $tags_arr = explode(',', $tags); foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } + if ($tag == $id_tag) + $groups_id[] = $group_id; } } } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; + if (array_search(0, $groups_id) === false) { + $groups_id_str = implode(",", $groups_id); + $groups_clause = " AND tagente.id_grupo IN ($groups_id_str)"; + } } $sql = "SELECT COUNT(talert_template_modules.id) @@ -1695,76 +1760,29 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric return $acltags; } -/** - * Get unknown agents filtering by id_tag. - * - * @param int $id_tag Id of the tag to search unknown agents - * - * @return mixed Returns count of unknown agents with this tag or false if they aren't. - */ -function tags_get_critical_agents ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; - } - - $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = " . $id_tag . " - AND tagente.critical_count>0 - $groups_clause"; - - return db_get_sql ($total_agents); -} - function tags_get_monitors_alerts ($id_tag, $groups_and_tags = array()) { // Avoid mysql error if (empty($id_tag)) return; - + $groups_clause = ""; if (!empty($groups_and_tags)) { - $i = 0; + + $groups_id = array(); foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { + if (!empty($tags)) { $tags_arr = explode(',', $tags); foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } + if ($tag == $id_tag) + $groups_id[] = $group_id; } } } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; + if (array_search(0, $groups_id) === false) { + $groups_id_str = implode(",", $groups_id); + $groups_clause = " AND tagente.id_grupo IN ($groups_id_str)"; + } } $sql = "SELECT COUNT(talert_template_modules.id) diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index b0dacdf8ed..f45cd4439a 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -32,7 +32,7 @@ if (! check_acl ($config['id_user'], 0, "AR")) { } $is_admin = check_acl ($config['id_user'], 0, "PM"); -$user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); +$user_strict = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); $force_refresh = get_parameter ("force_refresh", ""); if ($force_refresh == 1) { @@ -81,38 +81,81 @@ $data['agent_unknown'] = 0; $data['agent_not_init'] = 0; $data['global_health'] = 0; foreach ($all_data as $item) { - $data['monitor_checks'] += $item['_monitor_checks_']; - $data['monitor_not_init'] += $item['_monitors_not_init_']; - $data['monitor_unknown'] += $item['_monitors_unknown_']; - $data['monitor_ok'] += $item['_monitors_ok_']; - $data['monitor_bad'] += $item['_monitor_bad_']; - $data['monitor_warning'] += $item['_monitors_warning_']; - $data['monitor_critical'] += $item['_monitors_critical_']; - $data['monitor_not_normal'] += $item['_monitor_not_normal_']; - $data['monitor_alerts'] += $item['_monitors_alerts_']; - $data['monitor_alerts_fired'] += $item['_monitors_alerts_fired_']; + $data['monitor_checks'] += (int) $item['_monitor_checks_']; + $data['monitor_not_init'] += (int) $item['_monitors_not_init_']; + $data['monitor_unknown'] += (int) $item['_monitors_unknown_']; + $data['monitor_ok'] += (int) $item['_monitors_ok_']; + $data['monitor_bad'] += (int) $item['_monitor_bad_']; + $data['monitor_warning'] += (int) $item['_monitors_warning_']; + $data['monitor_critical'] += (int) $item['_monitors_critical_']; + $data['monitor_not_normal'] += (int) $item['_monitor_not_normal_']; + $data['monitor_alerts'] += (int) $item['_monitors_alerts_']; + $data['monitor_alerts_fired'] += (int) $item['_monitors_alerts_fired_']; if (isset($item['_total_agents_'])) - $data['total_agents'] += $item['_total_agents_']; + $data['total_agents'] += (int) $item['_total_agents_']; if (isset($item['_total_alerts_'])) - $data['total_alerts'] += $item['_total_alerts_']; + $data['total_alerts'] += (int) $item['_total_alerts_']; if (isset($item['_total_checks_'])) - $data['total_checks'] += $item['_total_checks_']; + $data['total_checks'] += (int) $item['_total_checks_']; - $data['alerts'] += $item['_alerts_']; - $data['agents_unknown'] += $item['_agents_unknown_']; - $data['monitor_health'] += $item['_monitor_health_']; - $data['alert_level'] += $item['_alert_level_']; - $data['module_sanity'] += $item['_module_sanity_']; - $data['server_sanity'] += $item['_server_sanity_']; - $data['agent_ok'] += $item['_agents_ok_']; - $data['agent_warning'] += $item['_agents_warning_']; - $data['agent_critical'] += $item['_agents_critical_']; - $data['agent_unknown'] += $item['_agents_unknown_']; - $data['agent_not_init'] += $item['_agents_not_init_']; - $data['global_health'] += $item['_global_health_']; + $data['alerts'] += (int) $item['_alerts_']; + $data['agent_ok'] += (int) $item['_agents_ok_']; + $data['agents_unknown'] += (int) $item['_agents_unknown_']; + $data['agent_warning'] += (int) $item['_agents_warning_']; + $data['agent_critical'] += (int) $item['_agents_critical_']; + $data['agent_unknown'] += (int) $item['_agents_unknown_']; + $data['agent_not_init'] += (int) $item['_agents_not_init_']; + + // Percentages + $data['server_sanity'] += (int) $item['_server_sanity_']; + $data['monitor_health'] += (int) $item['_monitor_health_']; + $data['module_sanity'] += (int) $item['_module_sanity_']; + $data['alert_level'] += (int) $item['_alert_level_']; + $data['global_health'] += (int) $item['_global_health_']; +} + +// Percentages +if (!empty($all_data)) { + if ($data["monitor_not_normal"] > 0 && $data["monitor_checks"] > 0) { + $data['monitor_health'] = format_numeric (100 - ($data["monitor_not_normal"] / ($data["monitor_checks"] / 100)), 1); + } + else { + $data["monitor_health"] = 100; + } + + if ($data["monitor_not_init"] > 0 && $data["monitor_checks"] > 0) { + $data["module_sanity"] = format_numeric (100 - ($data["monitor_not_init"] / ($data["monitor_checks"] / 100)), 1); + } + else { + $data["module_sanity"] = 100; + } + + if (isset($data["alerts"])) { + if ($data["monitor_alerts_fired"] > 0 && $data["alerts"] > 0) { + $data["alert_level"] = format_numeric (100 - ($data["monitor_alerts_fired"] / ($data["alerts"] / 100)), 1); + } + else { + $data["alert_level"] = 100; + } + } + else { + $data["alert_level"] = 100; + $data["alerts"] = 0; + } + + $data["monitor_bad"] = $data["monitor_critical"] + $data["monitor_warning"]; + + if ($data["monitor_bad"] > 0 && $data["monitor_checks"] > 0) { + $data["global_health"] = format_numeric (100 - ($data["monitor_bad"] / ($data["monitor_checks"] / 100)), 1); + } + else { + $data["global_health"] = 100; + } + + $data["server_sanity"] = format_numeric (100 - $data["module_sanity"], 1); } echo ''; @@ -132,7 +175,6 @@ $table->style = array (); $table->data[0][0] = reporting_get_stats_indicators($data, 120, 20); $table->rowclass[] = ''; - html_print_table ($table); unset($table); @@ -148,8 +190,16 @@ $table->head = array (); $table->data = array (); $table->style = array (); +$data_agents = array( + __('Critical') => $data['monitor_critical'], + __('Warning') => $data['monitor_warning'], + __('Normal') => $data['monitor_ok'], + __('Unknown') => $data['monitor_unknown'], + __('Not init') => $data['monitor_not_init'] + ); + $table->data[0][0] = reporting_get_stats_alerts($data); -$table->data[0][0] .= reporting_get_stats_modules_status($data, 180, 100); +$table->data[0][0] .= reporting_get_stats_modules_status($data, 180, 100, false, $data_agents); $table->data[0][0] .= reporting_get_stats_agents_monitors($data); $table->rowclass[] = ''; @@ -185,9 +235,14 @@ echo '
1 AND ($tags_condition)", 10, "100%"); +if (!empty($acltags)) { + $tags_condition = tags_get_acl_tags_event_condition($acltags, false, $user_strict); + + if (!empty($tags_condition)) { + events_print_event_table ("estado<>1 AND ($tags_condition)", 10, "100%"); + } +} // --------------------------------------------------------------------- // Server information