diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql index 23ba9562fa..05977d3052 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql @@ -49,7 +49,3 @@ CREATE TABLE IF NOT EXISTS `tuser_double_auth` ( -- ---------------------------------------------------------------------- INSERT INTO `ttipo_modulo` VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'); --- --------------------------------------------------------------------- --- Table `tusuario` --- --------------------------------------------------------------------- -ALTER TABLE `tusuario` ADD COLUMN `strict_acl` tinyint(1) DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql index 0f2d7a21f8..dcf223f6cc 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql @@ -36,8 +36,3 @@ CREATE OR REPLACE TRIGGER tuser_double_auth_inc BEFORE INSERT ON tuser_double_au -- Table `ttipo_modulo` -- ---------------------------------------------------------------------- INSERT INTO ttipo_modulo VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'); - --- --------------------------------------------------------------------- --- Table `tusuario` --- --------------------------------------------------------------------- -ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5,0) DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql index f6fd488be9..a0b2640837 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql @@ -34,8 +34,3 @@ CREATE TABLE "tuser_double_auth" ( -- Table `ttipo_modulo` -- ---------------------------------------------------------------------- INSERT INTO "ttipo_modulo" VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'); - --- --------------------------------------------------------------------- --- Table `tusuario` --- --------------------------------------------------------------------- -ALTER TABLE "tusuario" ADD COLUMN "strict_acl" SMALLINT NOT NULL default 0; diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 9558f40003..66fa34af2a 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -123,7 +123,6 @@ if ($new_user && $config['admin_can_add_user']) { $user_info['is_admin'] = 0; $user_info['language'] = 'default'; $user_info["not_login"] = false; - $user_info["strict_acl"] = false; if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { $user_info['id_skin'] = ''; } @@ -173,7 +172,6 @@ if ($create_user) { } } $values["not_login"] = (bool)get_parameter ('not_login', false); - $values["strict_acl"] = (bool)get_parameter ('strict_acl', false); if ($id == '') { ui_print_error_message (__('User ID cannot be empty')); @@ -237,11 +235,6 @@ if ($create_user) { $password_confirm = ''; if($result) { - if ($values["strict_acl"]) { - if ($values['is_admin']) { - ui_print_info_message (__('Strict ACL is not recommended for admin users because performance could be affected.')); - } - } $user_info = get_user_info ($id); $new_user = false; } @@ -276,7 +269,6 @@ if ($update_user) { $values['metaconsole_access_node'] = get_parameter ('metaconsole_access_node', '0'); } $values["not_login"] = (bool)get_parameter ('not_login', false); - $values["strict_acl"] = (bool)get_parameter ('strict_acl', false); $res1 = update_user ($id, $values); @@ -344,25 +336,6 @@ if ($update_user) { __('Error updating user info (no change?)')); } - if ($values['strict_acl']) { - $count_groups = 0; - $count_tags = 0; - - $profiles = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id); - if ($profiles === false) { - $profiles = array (); - } - foreach ($profiles as $profile) { - $count_groups = $count_groups+1; - $arr_tags = explode(',', $profile['tags']); - $count_tags = $count_tags + count($arr_tags); - } - - if (($count_groups > 3) && ($count_tags > 10)) { - ui_print_info_message(__('Strict ACL is not recommended for this user. Performance could be affected.')); - } - } - $user_info = $values; } @@ -523,10 +496,6 @@ $table->data[13][0] = __('Not Login'); $table->data[13][0] .= ui_print_help_tip(__('The user with not login set only can access to API.'), true); $table->data[13][1] = html_print_checkbox('not_login', 1, $user_info["not_login"], true); -$table->data[14][0] = __('Strict ACL'); -$table->data[14][0] .= ui_print_help_tip(__('With this option enabled, the user will can access to accurate information. It is not recommended for admin users because performance could be affected'), true); -$table->data[14][1] = html_print_checkbox('strict_acl', 1, $user_info["strict_acl"], true); - if($meta) { enterprise_include('include/functions_metaconsole.php'); $data = array(); diff --git a/pandora_console/include/ajax/template_wizard.ajax.php b/pandora_console/include/ajax/template_wizard.ajax.php deleted file mode 100644 index 46e4da34f0..0000000000 --- a/pandora_console/include/ajax/template_wizard.ajax.php +++ /dev/null @@ -1,65 +0,0 @@ - $v) { - $agents_aux[$keys_prefix . $k] = $v; - //unset($agents[$k]); - } - } - $agents = $agents_aux; - } - - echo json_encode ($agents); - return; -} -?> diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 72d37f44a2..c7e5fcc551 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -114,7 +114,8 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values * @return array All simple alerts defined for an agent. Empty array if no * alerts found. */ -function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', $allModules = false, $orderby = false, $idGroup = false, $count = false, $strict_user = false, $tag = false) { +function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', + $allModules = false, $orderby = false, $idGroup = false, $count = false) { global $config; if (is_array($filter)) { @@ -148,10 +149,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f $filter .= ''; break; } - - if ($tag) { - $filter .= ' AND (id_agent_module IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN ('.$tag.')))'; - } + if (is_array ($options)) { $filter .= db_format_array_where_clause_sql ($options); } @@ -159,7 +157,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f if (($id_agent !== false) && ($idGroup !== false)) { $groups = users_get_groups($config["id_user"]); - //$where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); + $where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); if ($idGroup != 0) { //All group $subQuery = 'SELECT id_agente_modulo FROM tagente_modulo @@ -170,15 +168,12 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f FROM tagente_modulo WHERE delete_pending = 0'; } - if ($strict_user) { - $where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); - // If there are any errors add imposible condition - if(in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { - $subQuery .= ' AND 1 = 0'; - } - else { - $subQuery .= $where_tags; - } + // If there are any errors add imposible condition + if(in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { + $subQuery .= ' AND 1 = 0'; + } + else { + $subQuery .= $where_tags; } } else if ($id_agent === false) { diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 44feff82a0..97b4dc0145 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1521,8 +1521,8 @@ function get_alert_fires_in_period ($id_alert_module, $period, $date = 0) { */ function get_group_alerts($id_group, $filter = '', $options = false, $where = '', $allModules = false, $orderby = false, - $idGroup = false, $count = false, $strict_user = false, $tag = false) { - + $idGroup = false, $count = false) { + global $config; $group_query = ''; @@ -1561,20 +1561,18 @@ function get_group_alerts($id_group, $filter = '', $options = false, $filter .= ''; break; } - - if ($tag) { - $filter .= ' AND (id_agent_module IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN ('.$tag.')))'; - } + if (is_array ($options)) { $filter .= db_format_array_where_clause_sql ($options); } if ($id_group !== false) { - $groups = users_get_groups($config["id_user"], "AR"); - - //$where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); - + $groups = users_get_groups($config["id_user"]); + + $where_tags = tags_get_acl_tags($config['id_user'], + array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); + if ($id_group != 0) { if (is_array($id_group)) { if (in_array(0, $id_group)) { @@ -1611,23 +1609,13 @@ function get_group_alerts($id_group, $filter = '', $options = false, $subQuery = 'SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 0'; } - - if ($strict_user) { - $groups = users_get_groups($config["id_user"]); - - if ($idGroup !== 0) { - $where_tags = tags_get_acl_tags($config['id_user'], $idGroup, 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); - } else { - $where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); - } - // If there are any errors add imposible condition - if (in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { - $subQuery .= ' AND 1 = 0'; - } - else { - $subQuery .= $where_tags; - } + // If there are any errors add imposible condition + if (in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { + $subQuery .= ' AND 1 = 0'; + } + else { + $subQuery .= $where_tags; } } else { diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index e5ee57fc7c..c07aae0ae0 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1125,7 +1125,7 @@ function groups_create_group($group_name, $rest_values){ // Get agents NOT INIT -function groups_agent_not_init ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_not_init ($group_array) { // If there are not groups to query, we jump to nextone @@ -1140,28 +1140,14 @@ function groups_agent_not_init ($group_array, $strict_user = false, $id_group_st $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count = 0 - AND warning_count = 0 - AND unknown_count = 0 - AND (notinit_count > 0 OR total_count = 0) - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) - FROM tagente - WHERE disabled = 0 - AND critical_count = 0 - AND warning_count = 0 - AND unknown_count = 0 - AND (notinit_count > 0 OR total_count = 0) - AND id_grupo IN $group_clause"); - } + $count = db_get_sql ("SELECT COUNT(*) + FROM tagente + WHERE disabled = 0 + AND critical_count = 0 + AND warning_count = 0 + AND unknown_count = 0 + AND (notinit_count > 0 OR total_count = 0) + AND id_grupo IN $group_clause"); return $count > 0 ? $count : 0; } @@ -1169,7 +1155,7 @@ function groups_agent_not_init ($group_array, $strict_user = false, $id_group_st // Get unknown agents by using the status code in modules. -function groups_agent_unknown ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_unknown ($group_array) { if (empty ($group_array)) { return 0; @@ -1181,24 +1167,12 @@ function groups_agent_unknown ($group_array, $strict_user = false, $id_group_str $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count=0 - AND warning_count=0 AND unknown_count>0 - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); - } + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); return $count > 0 ? $count : 0; } -function groups_agent_total($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_total($group_array) { if (empty ($group_array)) { return 0; @@ -1210,30 +1184,19 @@ function groups_agent_total($group_array, $strict_user = false, $id_group_strict $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - if ($strict_user) { - - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente - WHERE tagente.disabled = 0 - AND id_grupo = ".$id_group_strict . - $tags_clause; - - $count = db_get_sql($sql); - - } else { - $count = db_get_sql ("SELECT COUNT(*) + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled = 0 - AND id_grupo IN $group_clause"); - } + AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; } // Get ok agents by using the status code in modules. -function groups_agent_ok ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_ok ($group_array) { if (empty ($group_array)) { return 0; @@ -1246,30 +1209,179 @@ function groups_agent_ok ($group_array, $strict_user = false, $id_group_strict = $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count=0 - AND warning_count=0 AND normal_count = total_count - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) - FROM tagente - WHERE tagente.disabled = 0 - AND normal_count = total_count - AND id_grupo IN $group_clause"); - } - + $count = db_get_sql ("SELECT COUNT(*) + FROM tagente + WHERE tagente.disabled = 0 + AND normal_count = total_count + AND id_grupo IN $group_clause"); + + + return $count > 0 ? $count : 0; } // Get critical agents by using the status code in modules. -function groups_agent_critical ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_critical ($group_array) { + + 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 . ")"; + + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + +// Get warning agents by using the status code in modules. + +function groups_agent_warning ($group_array) { + + 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 . ")"; + + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + + +// Get monitor NOT INIT, except disabled AND async modules + +function groups_monitor_not_init ($group_array) { + + // 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 . ")"; + + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + +// Get monitor OK, except disabled and non-init + +function groups_monitor_ok ($group_array) { + + // 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 . ")"; + + //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; +} + +// Get monitor CRITICAL, except disabled and non-init + +function groups_monitor_critical ($group_array) { + + // 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 . ")"; + + //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; +} + +// Get monitor WARNING, except disabled and non-init + +function groups_monitor_warning ($group_array) { + + // 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 . ")"; + + //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; +} + +// Get monitor UNKNOWN, except disabled and non-init + +function groups_monitor_unknown ($group_array) { + + // 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 . ")"; + + //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; +} + +// Get alerts defined for a given group, except disabled + +function groups_monitor_alerts ($group_array) { + + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { return 0; @@ -1284,281 +1396,18 @@ function groups_agent_critical ($group_array, $strict_user = false, $id_group_st //TODO REVIEW ORACLE AND POSTGRES - if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count>0 - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; -} - -// Get warning agents by using the status code in modules. - -function groups_agent_warning ($group_array, $strict_user = false, $id_group_strict = false) { - - 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.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count=0 - AND warning_count>0 - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; -} - - -// Get monitor NOT INIT, except disabled AND async modules - -function groups_monitor_not_init ($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 = 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"); - } - - return $count > 0 ? $count : 0; -} - -// 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) { - $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 = 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; -} - -// 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; -} - -// 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; -} - -// 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; -} - -// Get alerts defined for a given group, except disabled - -function groups_monitor_alerts ($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)"; - $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"; - $count = db_get_sql ($sql); - return $count; - - } else { - - //TODO REVIEW ORACLE AND POSTGRES - return db_get_sql ("SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo IN $group_clause 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"); - } + return db_get_sql ("SELECT COUNT(talert_template_modules.id) + FROM talert_template_modules, tagente_modulo, tagente_estado, tagente + WHERE tagente.id_grupo IN $group_clause 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"); } // Get alert configured currently FIRED, except disabled -function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_monitor_fired_alerts ($group_array) { // If there are not groups to query, we jump to nextone @@ -1573,33 +1422,16 @@ function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_gr $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)"; - - $sql = "SELECT COUNT(talert_template_modules.id) + //TODO REVIEW ORACLE AND POSTGRES + + return db_get_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 + WHERE tagente.id_grupo IN $group_clause 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 - AND times_fired > 0 ".$tags_clause; - - $count = db_get_sql ($sql); - return $count; - } else { - //TODO REVIEW ORACLE AND POSTGRES - return db_get_sql ("SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo IN $group_clause 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 - AND times_fired > 0"); - } - + AND times_fired > 0"); } /** @@ -1798,6 +1630,8 @@ function groups_get_tree(&$groups, $parent = false) { return $return; } + + function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { global $config; @@ -1812,10 +1646,12 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { $propagate = db_get_value('propagate','tgrupo','id_grupo',$parent); if ($propagate == 1) { + //$childrens_ids_parent = array($parent); $hierarchy[] = $parent; $childrens = groups_get_childrens($parent); if (!empty($childrens)) { foreach ($childrens as $child) { + //$childrens_ids_parent[] = (int)$child['id_grupo']; $hierarchy[] = (int)$child['id_grupo']; } } @@ -1826,325 +1662,4 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { } return $hierarchy; } - -function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group') { - global $config; - - if ($id_user == false) { - $id_user = $config['id_user']; - } - - $user_groups = array(); - $user_tags = array(); - foreach ($acltags as $group => $tags) { - if ($user_strict) { //Remove groups with tags - if ($tags == '') { - $groups_without_tags[$group] = $group; - } - } - $user_groups[$group] = groups_get_name($group); - if ($tags != '') { - $tags_group = explode(',', $tags); - - foreach ($tags_group as $tag) { - $user_tags[$tag] = tags_get_name($tag); - } - } - } - - if ($user_strict) { - $user_groups_ids = implode(',',array_keys($groups_without_tags)); - } else { - $user_groups_ids = implode(',',array_keys($acltags)); - } - - if ($user_groups_ids == '') { - $user_groups_ids == -1; - } - - switch ($config["dbtype"]) { - case "mysql": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - ORDER BY nombre COLLATE utf8_general_ci ASC"); - - break; - case "postgresql": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - ORDER BY nombre ASC"); - break; - case "oracle": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - ORDER BY nombre COLLATE utf8_general_ci ASC"); - break; - } - - if ($list_groups == false) { - $list_groups = array(); - } - - if ($returnAllGroup) { - $i = 1; - $list[0]['_id_'] = 0; - $list[0]['_name_'] = __('All'); - } else { - $i = 0; - } - foreach ($list_groups as $key => $item) { - $id = $item['id_grupo']; - - if (($config["realtimestats"] == 0) && !$user_strict) { - $group_stat = db_get_all_rows_sql ("SELECT * - FROM tgroup_stat, tgrupo - WHERE tgrupo.id_grupo = tgroup_stat.id_group - AND tgroup_stat.id_group = $id - ORDER BY nombre"); - - $list[$i]['_id_'] = $id; - $list[$i]['_name_'] = $item['nombre']; - $list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;')); - - $list[$i]['_agents_unknown_'] = $group_stat[0]["unknown"]; - $list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"]; - $list[$i]['_total_agents_'] = $group_stat[0]["agents"]; - - if ($mode == 'tactical') { - $list[$i]['_agents_ok_'] = $group_stat[0]["normal"]; - $list[$i]['_agents_warning_'] = $group_stat[0]["warning"]; - $list[$i]['_agents_critical_'] = $group_stat[0]["critical"]; - $list[$i]['_monitors_alerts_'] = $group_stat[0]["alerts"]; - } - - // This fields are not in database - $list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id); - $list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id); - $list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id); - $list[$i]['_monitors_unknown_'] = groups_monitor_unknown($id, $user_strict, $id); - $list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id); - $list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id); - - if ($returnAllGroup) { - $list[0]['_agents_unknown_'] += $group_stat[0]["unknown"]; - $list[0]['_monitors_alerts_fired_'] += $group_stat[0]["alerts_fired"]; - $list[0]['_total_agents_'] += $group_stat[0]["agents"]; - $list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_']; - $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']; - - if ($mode == 'tactical') { - $list[0]['_agents_ok_'] += $group_stat[0]["normal"]; - $list[0]['_agents_warning_'] += $group_stat[0]["warning"]; - $list[0]['_agents_critical_'] += $group_stat[0]["critical"]; - $list[0]['_monitors_alerts_'] += $group_stat[0]["alerts"]; - } - } - - if ($mode == 'group') { - 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]); - } - } - } - - } else { - $list[$i]['_id_'] = $id; - $list[$i]['_name_'] = $item['nombre']; - $list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;')); - - $list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id); - $list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id); - $list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id); - $list[$i]['_agents_unknown_'] = groups_agent_unknown ($id, $user_strict, $id); - $list[$i]['_monitors_alerts_fired_'] = groups_monitor_fired_alerts ($id, $user_strict, $id); - $list[$i]['_total_agents_'] = groups_agent_total ($id, $user_strict, $id); - $list[$i]['_monitors_unknown_'] = groups_monitor_unknown($id, $user_strict, $id); - $list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id); - $list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id); - - if ($mode == 'tactical') { - $list[$i]['_agents_ok_'] = groups_agent_ok ($id, $user_strict, $id); - $list[$i]['_agents_warning_'] = groups_agent_warning ($id, $user_strict, $id); - $list[$i]['_agents_critical_'] = groups_agent_critical ($id, $user_strict, $id); - $list[$i]['_monitors_alerts_'] = groups_monitor_alerts ($id, $user_strict, $id); - } - - if ($returnAllGroup) { - $list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_']; - $list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_']; - $list[0]['_total_agents_'] += $list[$i]['_total_agents_']; - $list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_']; - $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']; - - if ($mode == 'tactical') { - $list[0]['_agents_ok_'] += $list[$i]['_agents_ok_']; - $list[0]['_agents_warning_'] += $list[$i]['_agents_warning_']; - $list[0]['_agents_critical_'] += $list[$i]['_agents_critical_']; - $list[0]['_monitors_alerts_'] += $list[$i]['_monitors_alerts_']; - } - } - - if ($mode == 'group') { - 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++; - } - - if ($user_strict) { - 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_'] = tags_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]['_monitors_critical_'] = tags_monitors_critical ($id, $acltags); - $list[$i]['_monitors_warning_'] = tags_monitors_warning ($id, $acltags); - $list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags); - - if ($mode == 'tactical') { - $list[$i]['_agents_ok_'] = tags_agent_ok ($id, $acltags); - $list[$i]['_agents_warning_'] = tags_agent_warning ($id, $acltags); - $list[$i]['_agents_critical_'] = tags_get_critical_agents ($id, $acltags); - $list[$i]['_monitors_alerts_'] = tags_get_monitors_alerts ($id, $acltags); - } - - - if ($returnAllGroup) { - $list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_']; - $list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_']; - $list[0]['_total_agents_'] += $list[$i]['_total_agents_']; - $list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_']; - $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_']; - - if ($mode == 'tactical') { - $list[0]['_agents_ok_'] += $list[$i]['_agents_ok_']; - $list[0]['_agents_warning_'] += $list[$i]['_agents_warning_']; - $list[0]['_agents_critical_'] += $list[$i]['_agents_critical_']; - $list[0]['_monitors_alerts_'] += $list[$i]['_monitors_alerts_']; - } - } - - if ($mode == 'group') { - 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 group_get_groups_list($id_user = false, $user_strict = false, $access = 'AR', $force_group_and_tag = true, $returnAllGroup = false, $mode = 'group') { - global $config; - - if ($id_user == false) { - $id_user = $config['id_user']; - } - - $acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict); - - if (! defined ('METACONSOLE')) { - $result_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode); - return $result_list; - } else { - $servers = db_get_all_rows_sql (" - SELECT * - FROM tmetaconsole_setup - WHERE disabled = 0"); - - if ($servers === false) { - $servers = array(); - } - - $result_list = array (); - foreach ($servers as $server) { - if (metaconsole_connect($server) != NOERR) { - continue; - } - $server_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode); - - 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_']; - - if ($mode == 'tactical') { - $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_']; - } - } - } - metaconsole_restore_db(); - - } - - return $result_list; - } -} - -function groups_get_group_deep ($id_group) { - global $config; - $parents = groups_get_parents($id_group, false); - - if (empty($parents)) { - $deep = ""; - } else { - $deep = str_repeat(" ", count($parents)); - } - - return $deep; -} ?> diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 357a1f54c6..4360409e56 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -368,36 +368,13 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false, - $keys_field = 'id_grupo', $strict_user = false) { + $keys_field = 'id_grupo') { global $config; $fields = users_get_groups_for_select($id_user, $privilege, $returnAllGroup, true, $id_group, $keys_field); - - if ($strict_user) { - foreach ($fields as $id => $group_name) { - $sql = "SELECT tags FROM tusuario_perfil WHERE id_usuario = '$id_user' AND id_grupo = $id"; - $group_has_tag = db_get_value_sql ($sql); - if (!$group_has_tag) { - - $sql_parent = "SELECT parent FROM tgrupo WHERE id_grupo = $id AND propagate = 1"; - $id_parent = db_get_value_sql($sql_parent); - - if ($id_parent) { - $sql_parent_aux = "SELECT tags FROM tusuario_perfil WHERE id_usuario = '$id_user' AND id_grupo = $id_parent"; - $parent_has_tag = db_get_value_sql ($sql_parent_aux); - - if ($parent_has_tag) { - unset($fields[$id]); - } - } - } else { - unset($fields[$id]); - } - } - } - + $output = html_print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, $return, $multiple, false, $class, $disabled, $style, $option_style); @@ -1489,13 +1466,22 @@ function html_print_table (&$table, $return = false) { if (!isset ($style[$key])) { $style[$key] = ''; } - - $output .= '