diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0abf3fcb59..c572e8ac0f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2008-10-08 Evi Vanoost + + * operation/agentes/estado_grupo.php: Fixed bug #2155213 and rewrote + cleaner HTML partially + 2008-10-08 Evi Vanoost * godmode/db/db_event.php: Didn't work for some or another reason. diff --git a/pandora_console/operation/agentes/estado_grupo.php b/pandora_console/operation/agentes/estado_grupo.php index d4fa5e7039..682c71b381 100644 --- a/pandora_console/operation/agentes/estado_grupo.php +++ b/pandora_console/operation/agentes/estado_grupo.php @@ -18,7 +18,7 @@ // Load global vars -require ("include/config.php"); +require_once ("include/config.php"); if (! isset($config["show_lastalerts"])) $config["show_lastalerts"] = 1; @@ -36,8 +36,8 @@ echo "

".__('Pandora Agents')." > ".__('Group view')."

"; // Made it a subquery, much faster on both the database and server side if (isset ($_GET["update_netgroup"])) { if (give_acl ($config['id_user'], $_GET["update_netgroup"], "AW")) { - $sql = sprintf ("UPDATE tagente_modulo SET `flag` = '1' WHERE `id_agente` = ANY(SELECT id_agente FROM tagente WHERE `id_grupo` = '%d')",$_GET["update_netgroup"]); - mysql_query ($sql); + $sql = sprintf ("UPDATE tagente_modulo SET `flag` = 1 WHERE `id_agente` = ANY(SELECT id_agente FROM tagente WHERE `id_grupo` = %d)",$_GET["update_netgroup"]); + process_sql ($sql); } } @@ -79,8 +79,8 @@ foreach ($groups as $id_group => $group_name) { AND tagente_modulo.disabled = 0 AND tagente_estado.utimestamp != 0", $id_group); - $result = mysql_query ($sql); - while ($module = mysql_fetch_assoc ($result)) { + $result = get_db_all_rows_sql ($sql); + foreach ($result as $module) { //if ($config["show_unknown"] > 0) { //this needs to be filled out somehow, but this was a serious bug. If that config var is set, it would short circuit both ok++ and bad++ returning empty for everything //} @@ -112,32 +112,39 @@ foreach ($groups as $id_group => $group_name) { } if ($total_agents == 0) { - echo "
".__('There are no defined groups')."
"; + echo '
'.__('There are no defined groups').'
'; if (give_acl ($config['id_user'], 0, "LM") || give_acl ($config['id_user'], 0, "AW") || give_acl ($config['id_user'], 0, "PM") || give_acl ($config['id_user'], 0, "DM") || give_acl ($config['id_user'], 0, "UM")) { - echo " 
"; + echo ' 
'; + print_submit_button (__('Create group'), 'crt', false, 'class="sub next"'); + echo '
'; } return; } $group_size = sizeof ($groups_info); $ancho = ceil (sqrt ($group_size + 1)); +$cells_across = $ancho; +if ($ancho > 5) { //If the cells would cross the line (more than 5) + $over = $ancho - 5; //Calculate how much we are over + $cells_across -= $over; //Take what we're over off cells_across + $ancho += $over; //And add them to ancho (which holds depth) +} $real_count = 0; -echo ""; +echo '
'; for ($table = 0; $table < $ancho; $table++) { if ($real_count >= $group_size) { continue; } - echo ""; + echo ''; //foreach ($groups_info as $group) { - for ($table_row = 0; $table_row < $ancho; $table_row++) { + for ($table_row = 0; $table_row < $cells_across; $table_row++) { if ($real_count >= $group_size) { continue; } @@ -147,125 +154,84 @@ for ($table = 0; $table < $ancho; $table++) { $icono_grupo = $group_info["icon"]; $icono_type = ""; if ($group_info["bad"] > 0) { - $icono_type .= ''; + $icono_type .= ''; } if ($group_info["ok"] > 0) { - $icono_type .= ''; + $icono_type .= ''; } // Show yellow light if there are recent alerts fired for this group if ($group_info["alerts"] > 0 ) { - $icono_type .= ''; + $icono_type .= ''; } // Show grey light if there are agent down for this group if ($group_info["down"] > 0 ) { - $icono_type .= ''; + $icono_type .= ''; } // Show red flag is group has disabled alert system if (give_disabled_group ($group_info["id_group"])) { - $icono_type .= ''; + $icono_type .= ''; } // By default green border - $celda = "
"; + $celda = ''; // Grey border if agent down if ($config["show_unknown"] > 0) { if ($group_info["down"] > 0) - $celda = ""; + $celda = ''; } // Yellow border if agents with alerts if ($group_info["alerts"] > 0) - $celda = ""; + $celda = ''; // Red border if agents bad if ($group_info["bad"] > 0) - $celda = ""; + $celda = ''; // Orange if alerts and down modules if (($group_info["bad"] > 0) && ($group_info["alerts"] > 0)) - $celda = ""; + $celda = ''; - $celda .= ""; + $celda .= ''; // Add group icon - $celda .= ""; + $celda .= ''; // Add float info table - $celda .= " - - - - -
". - __('Agents').":
". - $group_info["agent"]."
- - - - - - - - - - - - "; + $celda .= '
". - ucfirst (__('Monitors')).":
- - ".__('ok').": - ".$group_info["ok"]." -
- - ".__('Fail').": ". - $group_info["bad"]."
+ + +
'.__('Agents').':
'.$group_info["agent"].'
+ + + + + + '; + if ($config["show_unknown"] > 0) { - $celda .= " - - - "; + $celda .= ' + '; } + if ($config["show_lastalerts"] == 1) - $celda .= " - - - "; + $celda .= ' + '; + $celda .= "
'.__('Monitors').':
'.__('Ok').':'.$group_info["ok"].'
'.__('Fail').':'.$group_info["bad"].'
- - ".__('Down').": ". - $group_info["down"]."
'.__('Down').':'.$group_info["down"].'
- - ".__('Alerts').": ". - $group_info["alerts"]."
'.__('Alerts').':'.$group_info["alerts"].'
"; // Render network exec module button, only when this group is writtable by user if (give_acl ($config['id_user'], $group_info["id_group"], "AW")) { - $celda .= "  - "; + $celda .= ' '; } - $celda .= "

". - $icono_type."

- ".$group_name.""; + + $celda .= '

'.$icono_type.'

'.$group_name.''; + echo $celda; $real_count++; }