diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php
index 9201e50c18..d6efbc2d5f 100644
--- a/pandora_console/godmode/groups/group_list.php
+++ b/pandora_console/godmode/groups/group_list.php
@@ -32,39 +32,38 @@ if (is_ajax ()) {
require ("general/noaccess.php");
return;
}
-
+
$get_group_json = (bool) get_parameter ('get_group_json');
$get_group_agents = (bool) get_parameter ('get_group_agents');
$get_is_disabled = (bool) get_parameter ('get_is_disabled');
-
+
if ($get_group_json) {
$id_group = (int) get_parameter ('id_group');
-
+
if ($id_group == 0) {
$group = array('id_grupo' => 0,
- 'nombre' => 'All',
+ 'nombre' => 'All',
'icon' => 'world',
'parent' => 0,
'disabled' => 0,
'custom_id' => null);
-
echo json_encode ($group);
return;
}
-
+
if (! check_acl ($config['id_user'], $id_group, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access Alert Management");
echo json_encode (false);
return;
}
-
+
$group = db_get_row ('tgrupo', 'id_grupo', $id_group);
-
+
echo json_encode ($group);
return;
}
-
+
if ($get_group_agents) {
ob_clean();
$id_group = (int) get_parameter ('id_group');
@@ -86,33 +85,33 @@ if (is_ajax ()) {
$serialized = (bool)get_parameter('serialized', false);
$serialized_separator = (string)get_parameter('serialized_separator', "|");
$force_serialized = (bool)get_parameter('force_serialized', false);
-
+
if (! check_acl ($config['id_user'], $id_group, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access Alert Management");
echo json_encode (false);
return;
}
-
+
if ( https_is_running() ) {
header('Content-type: application/json');
}
-
+
if ($filter_agents_json != '') {
$filter['id_agente'] = json_decode(io_safe_output($filter_agents_json), true);
}
-
+
if ($all_agents) {
$filter['all_agents'] = true;
}
else {
$filter['disabled'] = $disabled;
}
-
+
if ($search != '') {
$filter['string'] = $search;
}
-
+
if ($status_agents != AGENT_STATUS_ALL) {
$filter['status'] = $status_agents;
}
@@ -120,10 +119,8 @@ if (is_ajax ()) {
# Juanma (22/05/2014) Fix: If remove void agents setted
$_sql_post = ' 1=1 ';
if ($show_void_agents == 0) {
-
$_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\'';
$filter[$_sql_post] = '1';
-
}
$id_groups_get_agents = $id_group;
@@ -192,7 +189,7 @@ if (is_ajax ()) {
$agents = $all_agents_array;
}
-
+
echo json_encode ($agents);
return;
}
@@ -208,11 +205,10 @@ if (is_ajax ()) {
echo json_encode($return);
return;
}
-
return;
}
-if (! check_acl($config['id_user'], 0, "AW")) {
+if (! check_acl($config['id_user'], 0, "PM")) {
db_pandora_audit("ACL Violation",
"Trying to access Group Management");
require ("general/noaccess.php");
@@ -221,24 +217,20 @@ if (! check_acl($config['id_user'], 0, "AW")) {
// Header
if (defined('METACONSOLE')) {
-
agents_meta_print_header();
$sec = 'advanced';
-
echo '
';
echo __("Edit or delete groups can cause problems with synchronization");
echo '
';
-
}
else {
-
- ui_print_page_header (__("Groups defined in %s", get_product_name()),
- "images/group.png", false, "", true, "");
+ ui_print_page_header (
+ __("Groups defined in %s", get_product_name()),
+ "images/group.png", false, "", true, ""
+ );
$sec = 'gagente';
-
}
-
$create_group = (bool) get_parameter ('create_group');
$update_group = (bool) get_parameter ('update_group');
$delete_group = (bool) get_parameter ('delete_group');
@@ -258,7 +250,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, "PM"))) {
$other = (string) get_parameter ('other');
$check = db_get_value('nombre', 'tgrupo', 'nombre', $name);
$propagate = (bool) get_parameter('propagate');
-
+
/*Check if name field is empty*/
if ($name != "") {
if (!$check) {
@@ -275,7 +267,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, "PM"))) {
'other' => $other,
'password' => io_safe_input($group_pass)
);
-
+
$result = db_process_sql_insert('tgrupo', $values);
if ($result) {
ui_print_success_message(__('Group successfully created'));
@@ -309,7 +301,7 @@ if ($update_group) {
$description = (string) get_parameter ('description');
$contact = (string) get_parameter ('contact');
$other = (string) get_parameter ('other');
-
+
/*Check if name field is empty*/
if ( $name != "") {
switch ($config["dbtype"]) {
@@ -332,7 +324,7 @@ if ($update_group) {
else {
$result = false;
}
-
+
if ($result !== false) {
ui_print_success_message(__('Group successfully updated'));
}
@@ -344,19 +336,19 @@ if ($update_group) {
/* Delete group */
if (($delete_group) && (check_acl($config['id_user'], 0, "PM"))) {
$id_group = (int) get_parameter ('id_group');
-
+
$usedGroup = groups_check_used($id_group);
-
+
if (!$usedGroup['return']) {
$group = db_get_row_filter('tgrupo',
array('id_grupo' => $id_group));
-
+
db_process_sql_update('tgrupo',
array('parent' => $group['parent']), array('parent' => $id_group));
-
+
$result = db_process_sql_delete('tgroup_stat',
array('id_group' => $id_group));
-
+
$result = db_process_sql_delete('tgrupo',
array('id_grupo' => $id_group));
}
@@ -364,136 +356,166 @@ if (($delete_group) && (check_acl($config['id_user'], 0, "PM"))) {
ui_print_error_message(
sprintf(__('The group is not empty. It is use in %s.'), implode(', ', $usedGroup['tables'])));
}
-
+
if ($result && (!$usedGroup['return'])) {
ui_print_success_message(__('Group successfully deleted'));
- }
+ }
else {
ui_print_error_message(__('There was a problem deleting group'));
}
}
-db_clean_cache();
-if ($create_group || $delete_group || $update_group) {
- $groups = users_get_groups ($config['id_user'], "AR", true, true, null, 'id_grupo', false);
- $groups = groups_get_groups_tree_recursive($groups);
-} else {
- $groups = users_get_groups_tree ($config['id_user'], "AR", true);
+$acl='';
+$search_name = '';
+$offset = (int)get_parameter('offset', 0);
+$search = (string)get_parameter('search', '');
+$block_size = $config['block_size'];
+
+if(!empty($search)){
+ $search_name = "AND t.nombre LIKE '%$search%'";
}
-$table = new StdClass();
-$table->width = '100%';
+if (!users_can_manage_group_all("AR")){
+ $user_groups_acl = users_get_groups(false, "AR");
+ $groups_acl = implode(",", $user_groups_ACL);
+ if(empty($groups_acl)) return ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) );
-$all_parents = array();
-$groups_count = 0;
-$sons = array();
-
-$groups_count = count($groups);
-
-foreach ($groups as $k => $g) {
- if ($g['parent'] != 0) {
- $all_parents[$g['parent']] = $g['parent'];
- }
-}
-krsort($all_parents);
-foreach ($all_parents as $parent) {
- foreach ($groups as $k => $g) {
- if ($g['parent'] == $parent) {
- $sons[$g['parent']][] = $g;
- unset($groups[$k]);
- }
- }
+ $acl = "AND t.id_grupo IN ($groups_acl)";
}
+$form = "";
+
+echo $form;
+
+$groups_sql =
+ "SELECT t.*,
+ p.nombre AS parent_name,
+ IF(t.parent=p.id_grupo, 1, 0) AS has_child
+ FROM tgrupo t
+ LEFT JOIN tgrupo p
+ ON t.parent=p.id_grupo
+ WHERE 1=1
+ $acl
+ $search_name
+ ORDER BY nombre
+ LIMIT $offset, $block_size
+";
+
+$groups = db_get_all_rows_sql($groups_sql);
if (!empty($groups)) {
+ //Count all groups for pagination only saw user and filters
+ $groups_sql_count = "SELECT count(*)
+ FROM tgrupo t
+ WHERE 1=1
+ $acl
+ $search_name
+ ";
+ $groups_count = db_get_value_sql($groups_sql_count);
+
+ $table = new StdClass();
+ $table->width = '100%';
$table->class = "databox data";
$table->head = array ();
- $table->head[0] = __('Name');
- $table->head[1] = __('ID');
+ $table->head[0] = __('ID');
+ $table->head[1] = __('Name');
$table->head[2] = __('Icon');
$table->head[3] = __('Alerts');
- $table->head[4] = __('Description');
- $table->head[5] = __('Actions');
+ $table->head[4] = __('Parent');
+ $table->head[5] = __('Description');
+ $table->head[6] = __('Actions');
$table->align = array ();
+ $table->align[0] = 'right';
$table->align[2] = 'left';
- $table->align[5] = 'left';
- $table->size[4] = '30%';
- $table->size[5] = '10%';
+ $table->align[6] = 'left';
+ $table->size[5] = '30%';
+ $table->size[6] = '10%';
$table->data = array ();
-
- $offset = (int)get_parameter('offset', 0);
- $limit = $offset + $config['block_size'];
-
-
-
- $pagination = ui_pagination($groups_count,
- false, 0, $config['block_size'], true, 'offset', false);
-
- $n = -1;
- $iterator = 0;
- $branch_classes = array();
- foreach ($groups as $group) {
- $n++;
-
- // Only print the page range
- if ($n < $offset || $n >= $limit) {
- continue;
+
+ foreach ($groups as $key => $group) {
+ $url = "index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group=".$group['id_grupo'];
+ $url_delete = "index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group=" . $group['id_grupo'];
+ $table->data[$key][0] = $group['id_grupo'];
+ $table->data[$key][1] = "" . $group['nombre'] . "";
+ $table->data[$key][2] = html_print_image(
+ "images/groups_small/" . $group['icon'] . ".png",
+ true,
+ array(
+ "style" => '',
+ "class" => "bot",
+ "alt" => $group['nombre'],
+ "title" => $group['nombre'],
+ false, false, false, true
+ )
+ );
+
+ //reporting_get_group_stats
+ $table->data[$key][3] = $group['disabled'] ? __('Disabled') : __('Enabled');
+ $table->data[$key][4] = $group['parent_name'];
+ $table->data[$key][5] = $group['description'];
+ $table->data[$key][6] = "" .
+ html_print_image(
+ "images/config.png",
+ true,
+ array(
+ "alt" => __('Edit'),
+ "title" => __('Edit'),
+ "border" => '0'
+ )
+ ) .
+ "";
+
+ $confirm_message = __('Are you sure?');
+ if ($group['has_child']) {
+ $confirm_message = __('The child groups will be updated to use the parent id of the deleted group') . ". " . $confirm_message;
}
-
- $symbolBranchs = ' symbol_branch_' . $group['parent'];
-
- $has_children = isset($sons[$group['id_grupo']]);
- $data = groups_get_group_to_list($group, $groups_count, $symbolBranchs, $has_children);
- array_push ($table->data, $data);
- $table->rowstyle[$iterator] = '';
- if ($group['id_grupo'] != 0) {
- $branch_classes[$group['id_grupo']] = ' branch_0';
- $table->rowclass[$iterator] = 'parent_' . $group['parent'] . ' branch_0';
- }
- $iterator++;
-
- groups_print_group_sons($group, $sons, $branch_classes,
- $groups_count, $table, $iterator, $symbolBranchs);
+
+ $table->data[$key][6] .= ' ' .
+ '' .
+ html_print_image(
+ "images/cross.png",
+ true,
+ array(
+ "alt" => __('Delete'),
+ "title" => __('Delete'),
+ "border" => '0'
+ )
+ ) .
+ "";
+
}
-
- echo $pagination;
-
+
+ echo ui_pagination(
+ $groups_count, false,
+ $offset, $block_size,
+ true, 'offset', false
+ );
html_print_table ($table);
-
- echo $pagination;
+ echo ui_pagination(
+ $groups_count, false,
+ $offset, $block_size,
+ true, 'offset', true
+ );
}
else {
ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) );
}
if (check_acl($config['id_user'], 0, "PM")) {
- echo '';
}
enterprise_hook('close_meta_frame');
-
?>
-
-
diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php
index 75c08addc2..33118d39c2 100644
--- a/pandora_console/include/functions_graph.php
+++ b/pandora_console/include/functions_graph.php
@@ -4268,12 +4268,12 @@ function fullscale_data (
if(isset($v["datos"]) && $v["datos"]){
//max
- if($v['datos'] >= $max_value){
- $max_value = $v['datos'];
+ if((float)$v['datos'] >= $max_value_max){
+ $max_value_max = $v['datos'];
}
//min
- if($v['datos'] <= $min_value){
- $min_value = $v['datos'];
+ if((float)$v['datos'] <= $min_value_min){
+ $min_value_min = $v['datos'];
}
//avg sum
$sum_data += $v["datos"];
@@ -4288,8 +4288,9 @@ function fullscale_data (
$last_data = $v["datos"];
}
}
- $data["sum" . $series_suffix]['min'] = $min_value;
- $data["sum" . $series_suffix]['max'] = $max_value;
+
+ $data["sum" . $series_suffix]['min'] = $min_value_min;
+ $data["sum" . $series_suffix]['max'] = $max_value_max;
$data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
}
diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php
index 98c13d5db7..2ce647c324 100644
--- a/pandora_console/include/functions_groups.php
+++ b/pandora_console/include/functions_groups.php
@@ -270,22 +270,20 @@ function groups_get_childrens($parent, $groups = null, $onlyPropagate = false) {
if (empty($groups)) {
$groups = db_get_all_rows_in_table('tgrupo');
}
-
+
$return = array();
-
+
foreach ($groups as $key => $group) {
if ($group['id_grupo'] == 0) {
continue;
}
-
if ($group['propagate'] || $onlyPropagate) {
if ($group['parent'] == $parent) {
$return = $return + array($group['id_grupo'] => $group) + groups_get_childrens($group['id_grupo'], $groups, $onlyPropagate);
}
}
-
}
-
+
return $return;
}
@@ -300,23 +298,20 @@ function groups_get_parents($parent, $onlyPropagate = false, $groups = null) {
if (empty($groups)) {
$groups = db_get_all_rows_in_table('tgrupo');
}
-
+
$return = array();
-
foreach ($groups as $key => $group) {
if ($group['id_grupo'] == 0) {
continue;
}
-
+
if (($group['id_grupo'] == $parent)
&& ($group['propagate'] || !$onlyPropagate)) {
-
$return = $return +
array($group['id_grupo'] => $group) +
groups_get_parents($group['parent'], $onlyPropagate, $groups);
}
}
-
return $return;
}
@@ -373,32 +368,6 @@ function groups_give_disabled_group ($id_group) {
return (bool) db_get_value ('disabled', 'tgrupo', 'id_grupo', (int) $id_group);
}
-/**
- * Test if the param array is all groups in db.
- *
- * @param array $id_groups
- *
- * @return bool It's true when the array is all groups in db.
- */
-function groups_is_all_group($idGroups) {
- if (!is_array($idGroups))
- $arrayGroups = array($idGroups);
- else
- $arrayGroups = $idGroups;
-
- $groupsDB = db_get_all_rows_in_table ('tgrupo');
-
- $returnVar = true;
- foreach ($groupsDB as $group) {
- if (!in_array($group['id_grupo'], $arrayGroups)) {
- $returnVar = false;
- break;
- }
- }
-
- return $returnVar;
-}
-
/**
* Get group icon from group.
*
@@ -632,7 +601,7 @@ function groups_get_id ($group_name, $returnAllGroup = false) {
*
* @param int $id_group The group id to look for
* @param mixed filter array
- * @param bool True if users with all permissions in the group are retrieved
+ * @param bool True if users with all permissions in the group are retrieved
*
* @return array An array with all the users or an empty array
*/
@@ -641,7 +610,7 @@ function groups_get_users ($id_group, $filter = false, $return_user_all = false)
if (! is_array ($filter))
$filter = array ();
-
+
if($return_user_all){
if (is_array($id_group)){
$filter['id_grupo'] = $id_group;
@@ -655,18 +624,18 @@ function groups_get_users ($id_group, $filter = false, $return_user_all = false)
$filter['id_grupo'] = $id_group;
}
- $query = "SELECT tu.*
- FROM tusuario tu, tusuario_perfil tup
- WHERE tup.id_usuario = tu.id_user" ;
+ $query = "SELECT tu.*
+ FROM tusuario tu, tusuario_perfil tup
+ WHERE tup.id_usuario = tu.id_user" ;
if(is_array($filter)){
foreach ($filter as $key => $value) {
if($key != 'limit' && $key != 'order' &&
- $key != 'offset' &&$key != 'group'){
+ $key != 'offset' &&$key != 'group'){
$filter_array["tup.".$key] = $value;
}
else{
- $filter_array[$key] = $value;
+ $filter_array[$key] = $value;
}
}
$clause_sql = mysql_db_format_array_where_clause_sql($filter_array,'AND',false);
@@ -674,451 +643,16 @@ function groups_get_users ($id_group, $filter = false, $return_user_all = false)
$query .= " AND " . $clause_sql;
}
}
-
+
$result = db_get_all_rows_sql($query);
if ($result === false){
return array ();
}
-
+
return $result;
}
-/**
- * Returning data for a row in the groups view (Recursive function)
- *
- * @param int $id_group The group id of the row
- * @param array $group_all An array of all groups
- * @param array $group arrayy The group name and childs
- * @param array $printed_groups The printed groups list (by reference)
- *
- */
-function groups_get_group_row_data($id_group, $group_all, $group, &$printed_groups) {
- global $config;
-
- $rows = array();
- $row = array();
-
- if (isset($printed_groups[$id_group])) {
- return;
- }
-
- // Store printed group to not print it again
- $printed_groups[$id_group] = 1;
-
- if ($id_group < 0)
- return;
-
- // Get stats for this group
- $data = reporting_get_group_stats($id_group);
-
- if ($data["total_agents"] == 0)
- return; // Skip empty groups
-
- // Calculate entire row color
- if ($data["monitor_alerts_fired"] > 0) {
- $row["status"] = "group_view_alrm";
- }
- elseif ($data["monitor_critical"] > 0) {
- $row["status"] = "group_view_crit";
- }
- elseif ($data["monitor_warning"] > 0) {
- $row["status"] = "group_view_warn";
- }
- elseif (($data["monitor_unknown"] > 0) || ($data["agents_unknown"] > 0)) {
- $row["status"] = "group_view_unk";
- }
- elseif ($data["monitor_ok"] > 0) {
- $row["status"] = "group_view_ok";
- }
- else {
- $row["status"] = "group_view_normal";
- }
-
- // Group name
- $group_cell = __('Group');
- $row[$group_cell] = $group['prefix'];
- $row[$group_cell] .= "";
- $row[$group_cell] .= ui_print_group_icon ($id_group, true, "groups_small", '', false);
- $row[$group_cell] .= ui_print_truncate_text($group['name']);
- $row[$group_cell] .= "";
-
- $row['group_name'] = ui_print_truncate_text($group['name']);
-
- if ($id_group > 0)
- $icon = (string) db_get_value ('icon', 'tgrupo', 'id_grupo', (int) $id_group);
- else
- $icon = "world";
-
- $row['group_icon'] = html_print_image("images/groups_small/" . $icon . ".png",
- true, false, true);
-
- if (!isset($html)) {
- $html = false;
- }
-
- //Update network group
- if ($html) {
- echo "";
- if (check_acl ($config['id_user'], $id_group, "AW")) {
- echo '' .
- html_print_image("images/target.png", true, array("border" => '0', "alt" => __('Force'))) . '';
- }
- echo " | ";
- }
-
- // Total agents
- if ($id_group != 0) {
- $data["total_agents"] = db_get_sql ("SELECT COUNT(id_agente)
- FROM tagente
- WHERE id_grupo = $id_group AND disabled = 0");
- }
-
- // Total agents
- $row['links'][__('Agents')] = "index.php?" .
- "page=agents&group=" . $id_group;
- $row['counts'][__('Agents')] = $data["total_agents"];
-
- $row[__('Agents')] = "";
- $row[__('Agents')] .= $row['counts'][__('Agents')];
- $row[__('Agents')] .= "";
-
-
- // Agents unknown
- $row['links'][__('Agents unknown')] = "index.php?" .
- "page=agents&group=" . $id_group . "&status=" . AGENT_STATUS_UNKNOWN;
- $row['counts'][__('Agents unknown')] = $data["agents_unknown"];
-
- $row[__('Agents unknown')] = "";
- $row[__('Agents unknown')] .= $row['counts'][__('Agents unknown')];
- $row[__('Agents unknown')] .= "";
-
- // Monitors Unknown
- $row['links'][__('Unknown')] = "index.php?" .
- "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_UNKNOWN;
- $row['counts'][__('Unknown')] = $data["monitor_unknown"];
-
- $row[__('Unknown')] = "";
- $row[__('Unknown')] .= $row['counts'][__('Unknown')];
- $row[__('Unknown')] .= "";
-
- // Monitors Not Init
- $row['links'][__('Not init')] = "index.php?" .
- "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_NOT_INIT;
- $row['counts'][__('Not init')] = $data["monitor_unknown"];
-
- $row[__('Not init')] = "";
- $row[__('Not init')] .= $row['counts'][__('Not init')];
- $row[__('Not init')] .= "";
-
- // Monitors OK
- $row['links'][__('Normal')] = "index.php?" .
- "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_NORMAL;
- $row['counts'][__('Normal')] = $data["monitor_ok"];
-
- $row[__('Normal')] = "";
- $row[__('Normal')] .= $row['counts'][__('Normal')];
- $row[__('Normal')] .= "";
-
- // Monitors Warning
- $row['links'][__('Warning')] = "index.php?" .
- "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_WARNING;
- $row['counts'][__('Warning')] = $data["monitor_warning"];
-
- $row[__('Warning')] = "";
- $row[__('Warning')] .= $row['counts'][__('Normal')];
- $row[__('Warning')] .= "";
-
- // Monitors Critical
- $row['links'][__('Critical')] = "index.php?" .
- "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_CRITICAL_BAD;
- $row['counts'][__('Critical')] = $data["monitor_critical"];
-
- $row[__('Critical')] = "";
- $row[__('Critical')] .= $row['counts'][__('Critical')];
- $row[__('Critical')] .= "";
-
- // Alerts fired
- $row['links'][__('Alerts fired')] = "index.php?" .
- "page=alerts&group=" . $id_group . "&status=fired";
- $row['counts'][__('Alerts fired')] = $data["monitor_alerts_fired"];
-
- $row[__('Alerts fired')] = "";
- $row[__('Alerts fired')] .= $row['counts'][__('Alerts fired')];
- $row[__('Alerts fired')] .= "";
-
- $rows[$id_group] = $row;
-
- foreach($group['childs'] as $child) {
- $sub_rows = groups_get_group_row_data($child, $group_all,
- $group_all[$child], $printed_groups);
-
- if (!$html) {
- if (!empty($sub_rows))
- $rows = $rows + $sub_rows;
- }
- }
-
- return $rows;
-}
-
-function groups_get_groups_with_agent($id_user = false, $privilege = "AR", $returnAllGroup = true, $returnAllColumns = false, $id_groups = null, $keys_field = 'id_grupo') {
- $groups = users_get_groups($id_user, $privilege, $returnAllGroup, $returnAllColumns, $id_groups, $keys_field);
-
- $return = array();
- foreach ($groups as $group) {
- $data = reporting_get_group_stats($group['id_grupo']);
-
- if ($data["total_agents"] != 0) {
- $return[] = $group;
- }
- }
-
- return $return;
-}
-
-/**
- * Print a row in the groups view (Recursive function)
- *
- * @param int $id_group The group id of the row
- * @param array $group_all An array of all groups
- * @param array $group arrayy The group name and childs
- * @param array $printed_groups The printed groups list (by reference)
- *
- */
-function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) {
- global $config;
-
- if ($id_group < 0)
- return;
-
- if (isset($printed_groups[$id_group])) {
- return;
- }
-
- // Store printed group to not print it again
- $printed_groups[$id_group] = 1;
-
- // Get stats for this group
- $data = reporting_get_group_stats($id_group);
-
-
- if ($data["total_agents"] == 0) {
- if (!empty($group['childs'])) {
- $group_childrens = groups_get_childrens($id_group, null, true);
- $group_childrens_agents = groups_total_agents(array_keys($group_childrens));
-
- if (empty($group_childrens_agents)) {
- return; // Skip empty groups
- }
- }
- else {
- return; // Skip empty groups
- }
- }
-
- // Calculate entire row color
- if ($data["monitor_alerts_fired"] > 0) {
- $group_class = 'group_view_alrm';
- $status_image = ui_print_status_image ('agent_alertsfired_ball.png', "", true);
- }
- elseif ($data["monitor_critical"] > 0) {
- $group_class = 'group_view_crit';
- $status_image = ui_print_status_image ('agent_critical_ball.png', "", true);
- }
- elseif ($data["monitor_warning"] > 0) {
- $group_class = 'group_view_warn';
- $status_image = ui_print_status_image ('agent_warning_ball.png', "", true);
- }
- elseif (($data["monitor_unknown"] > 0) || ($data["agents_unknown"] > 0)) {
- $group_class = 'group_view_unk';
- $status_image = ui_print_status_image ('agent_no_monitors_ball.png', "", true);
- }
- elseif ($data["monitor_ok"] > 0) {
- $group_class = 'group_view_ok';
- $status_image = ui_print_status_image ('agent_ok_ball.png', "", true);
- }
- elseif ($data["agent_not_init"] > 0) {
- $group_class = 'group_view_not_init';
- $status_image = ui_print_status_image ('agent_no_data_ball.png', "", true);
- }
- else {
- $group_class = 'group_view_normal';
- $status_image = ui_print_status_image ('agent_no_data_ball.png', "", true);
- }
-
- ob_start();
-
- echo "";
-
- // Force
- echo "";
- if (check_acl ($config['id_user'], $id_group, "AW")) {
- echo '' .
- html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'))) . '';
- }
- echo " | ";
-
- // Status
- // echo "" . $status_image . " | ";
-
- // Group name
- echo " ";
- //echo $group['prefix'] . ui_print_group_icon ($id_group, true, "groups_small", 'font-size: 7.5pt');
- echo " ";
- echo $group['prefix'] . ui_print_truncate_text($group['name']);
- echo "";
- echo " | ";
-
- // Total agents
- echo "";
- if ($data["total_agents"] > 0)
- echo "";
-
- //Total agent field given by function reporting_get_group_stats return the number of agents
- //of this groups and its children. It was done to print empty fathers of children groups.
- //We need to recalculate the total agents for this group here to get only the total agents
- //for this group. Of course the group All (0) is a special case.
-
- if ($id_group != 0) {
- $data["total_agents"] = db_get_sql ("SELECT COUNT(id_agente)
- FROM tagente
- WHERE id_grupo = $id_group AND disabled = 0");
- }
-
- echo $data["total_agents"];
- echo "";
-
- // Agents unknown
- if ($data["agents_unknown"] > 0) {
- echo " | ";
- echo "";
- echo $data["agents_unknown"];
- echo "";
- echo " | ";
- }
- else {
- echo " | ";
- }
-
- // Agents not init
- if ($data["agent_not_init"] > 0) {
- echo "";
- echo "";
- echo $data["agent_not_init"];
- echo "";
- echo " | ";
- }
- else {
- echo " | ";
- }
-
- // Monitors Unknown
- if ($data["monitor_unknown"] > 0) {
- echo "";
- echo "";
- echo $data["monitor_unknown"];
- echo "";
- echo " | ";
- }
- else {
- echo " | ";
- }
-
-
- // Monitors Not Init
- if ($data["monitor_not_init"] > 0) {
- echo "";
- echo "";
- echo $data["monitor_not_init"];
- echo "";
- echo " | ";
- }
- else {
- echo " | ";
- }
-
-
- // Monitors OK
- echo "";
- if ($data["monitor_ok"] > 0) {
- echo "";
- echo $data["monitor_ok"];
- echo "";
- }
- else {
- echo " ";
- }
- echo " | ";
-
- // Monitors Warning
- if ($data["monitor_warning"] > 0) {
- echo "";
- echo "";
- echo $data["monitor_warning"];
- echo "";
- echo " | ";
- }
- else {
- echo " | ";
- }
-
- // Monitors Critical
- if ($data["monitor_critical"] > 0) {
- echo "";
- echo "";
- echo $data["monitor_critical"];
- echo "";
- echo " | ";
- }
- else {
- echo " | ";
- }
- // Alerts fired
- if ($data["monitor_alerts_fired"] > 0) {
- echo "";
- echo "";
- echo $data["monitor_alerts_fired"];
- echo "";
- echo " | ";
- }
- else {
- echo " | ";
- }
-
- echo "
";
-
- $row[$id_group] = ob_get_clean();
-
-
- foreach ($group['childs'] as $child) {
- if (array_key_exists($child, $group_all)) {
- $row_child = groups_get_group_row($child, $group_all, $group_all[$child], $printed_groups);
-
- if (!is_array_empty($row_child)) {
- $row = $row + $row_child;
- }
- }
- }
-
- return $row;
-}
-
/**
* Gets a group by id_group
*
@@ -2111,172 +1645,6 @@ function groups_agents_total_counters ($group_array) {
return ($agents === false) ? $default_total : $agents;
}
-/**
- * Total agents in a group, (by default except disabled ones)
- *
- * @param mixed Array or (comma separated) string with groups
- * @param bool Whether to count disabled agents
- *
- * @return mixed Return group count or false if something goes wrong
- *
- */
-function groups_total_agents ($group_array, $disabled = 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 . ")";
-
- $sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause";
-
- if (!$disabled)
- $sql .= " AND disabled = 0";
-
- return db_get_sql ($sql);
-}
-
-/**
- * Number of disabled agents in a group
- *
- * @param mixed Array or (comma separated) string with groups
- *
- * @return mixed Return group count or false if something goes wrong
- *
- */
-function groups_agent_disabled ($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 . ")";
-
- $sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 1";
-
- return db_get_sql ($sql);
-}
-
-/**
- * Return a group row for Groups managment list
- *
- * @param mixed Group info
- * @param int total number of groups
- * @param string (ref) Concatenation of branches class with the parent classes
- *
- * @return mixed Row with html_print_table format
- *
- */
-function groups_get_group_to_list($group, $groups_count, &$symbolBranchs, $has_children = false) {
- $tabulation = str_repeat(' ', $group['deep']);
-
- if ($group['id_grupo'] == 0) {
- $symbol = '-';
- }
- else {
- $symbol = '+';
- }
-
- $group_hash_branch = false;
- if (isset($group['hash_branch'])) {
- $group_hash_branch = $group['hash_branch'];
- }
-
- if ($group_hash_branch) {
- $data[0] = ''.$tabulation . ' ' .
- '' .
- $symbol . ' '. ui_print_truncate_text($group['nombre']) . '';
- }
- else {
- $data[0] = '' . $tabulation . ' ' . ui_print_truncate_text($group['nombre']) . '';
- }
- $data[1] = $group['id_grupo'];
- $data[2] = ui_print_group_icon($group['id_grupo'], true);
- $data[3] = $group['disabled'] ? __('Disabled') : __('Enabled');
- $data[4] = $group['description'];
- if ($group['id_grupo'] == 0) {
- $data[5] = '';
- }
- else {
- $data[5] = '' . html_print_image("images/config.png", true, array("alt" => __('Edit'), "title" => __('Edit'), "border" => '0'));
- //Check if there is only a group to unable delete it
- if ($groups_count > 2) {
- $confirm_message = __('Are you sure?');
- if ($has_children) {
- $confirm_message = __('The child groups will be updated to use the parent id of the deleted group') . ". " . $confirm_message;
- }
-
- $data[5] .= ' ' .
- '' . html_print_image("images/cross.png", true, array("alt" => __('Delete'), "border" => '0'));
- }
- else {
- $data[5] .= ' ' .
- ui_print_help_tip(
- __('You cannot delete the last group. A common installation must have at least one group.'), true);
- }
- }
-
- return $data;
-}
-
-/**
- * Store to be printed the subgroups rows (Recursive)
- *
- * @param mixed Group info
- * @param mixed Hash list with all the groups of 2nd or higher level
- * @param string (ref) Concatenation of branches classes to control the symbols from Javascript
- * @param int total number of groups
- * @param obj (ref) table object in html_print_table format with the stored groups
- * @param int (ref) counter of the row stored
- * @param string (ref) Concatenation of branches class with the parent classes
- *
- */
-function groups_print_group_sons($group, $sons, &$branch_classes, $groups_count, &$table, &$iterator, &$symbolBranchs) {
- if (isset($sons[$group['id_grupo']])) {
- foreach($sons[$group['id_grupo']] as $key => $g) {
- $symbolBranchs .= ' symbol_branch_' . $g['parent'];
-
- $has_children = isset($sons[$g['id_grupo']]);
-
- $data = groups_get_group_to_list($g, $groups_count, $symbolBranchs, $has_children);
- array_push ($table->data, $data);
-
- $branch_classes[$g['id_grupo']] = $branch_classes[$g['parent']] . ' branch_' . $g['parent'];
- $table->rowclass[$iterator] = 'parent_' . $g['parent'] . $branch_classes[$g['id_grupo']];
-
- if ($g['deep'] == 0) {
- $table->rowstyle[$iterator] = '';
- }
- else {
- if ($g['parent'] != 0) {
- $table->rowstyle[$iterator] = 'display: none;';
- }
- }
-
- $iterator++;
-
- groups_print_group_sons($g, $sons, $branch_classes, $groups_count, $table, $iterator, $symbolBranchs);
- }
- }
-}
-
/**
* Return an array with the groups hierarchy (Recursive)
*
@@ -2369,39 +1737,6 @@ function groups_get_tree_keys ($groups, &$group_keys) {
}
}
-function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
- global $config;
-
- if ($id_group == 0) {
- $hierarchy = groups_get_childrens($id_group);
- }
- else {
- $hierarchy[] = $id_group;
- $parent = db_get_value('parent','tgrupo','id_grupo',$id_group);
-
- if ($parent !== 0) {
- $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'];
- }
- }
-
- $hierarchy = groups_get_all_hierarchy_group ($parent, $hierarchy);
- }
- }
- }
- return $hierarchy;
-}
-
-
-
function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group', $agent_filter = array(), $module_filter = array()) {
global $config;
if ($id_user == false) {
@@ -2942,77 +2277,6 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
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_groups_and_tags ($id_user, $access, $user_strict);
-
- // If using metaconsole, the strict users will use the agent table of every node
- if (is_metaconsole() && $user_strict) {
- $servers = metaconsole_get_servers();
-
- $result_list = array ();
- foreach ($servers as $server) {
-
- if (metaconsole_connect($server) != NOERR) {
- continue;
- }
- $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_'];
-
- $result_list[$server_item['_name_']]["_monitor_checks_"] += $server_item["_monitor_checks_"];
- $result_list[$server_item['_name_']]["_monitor_not_normal_"] += $server_item["_monitor_not_normal_"];
- $result_list[$server_item['_name_']]["_monitor_health_"] += $server_item["_monitor_health_"];
- $result_list[$server_item['_name_']]["_module_sanity_"] += $server_item["_module_sanity_"];
- $result_list[$server_item['_name_']]["_alerts_"] += $server_item["_alerts_"];
- $result_list[$server_item['_name_']]["_alert_level_"] += $server_item["_alert_level_"];
- $result_list[$server_item['_name_']]["_monitor_bad_"] += $server_item["_monitor_bad_"];
- $result_list[$server_item['_name_']]["_global_health_"] += $server_item["_global_health_"];
- $result_list[$server_item['_name_']]["_server_sanity_"] += $server_item["_server_sanity_"];
- $result_list[$server_item['_name_']]["_monitor_alerts_fire_count_"] += $server_item["_monitor_alerts_fire_count_"];
- $result_list[$server_item['_name_']]["_total_checks_"] += $server_item["_total_checks_"];
- $result_list[$server_item['_name_']]["_total_alerts_"] += $server_item["_total_alerts_"];
- }
- }
- }
- metaconsole_restore_db();
-
- }
-
- return $result_list;
- }
- // If using metaconsole, the not strict users will use the metaconsole's agent cache table
- else {
- $result_list = group_get_data ($id_user, $user_strict, $acltags,
- $returnAllGroup, $mode);
-
- return $result_list;
- }
-}
-
function groups_get_group_deep ($id_group) {
global $config;
diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php
index 7c41cf8565..578c0c6af4 100755
--- a/pandora_console/operation/agentes/tactical.php
+++ b/pandora_console/operation/agentes/tactical.php
@@ -56,7 +56,6 @@ ui_print_page_header (__("Tactical view"), "", false, "", false, $updated_time);
//Currently this function makes loading this page is impossible. Change
//and create new function.
-//$all_data = group_get_groups_list($config['id_user'], $user_strict, 'AR', true, false, 'tactical');
$all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict);