2008-10-08 Evi Vanoost <vanooste@rcbi.rochester.edu>

* operation/agentes/estado_grupo.php: Fixed bug #2155213 and rewrote
        cleaner HTML partially

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1135 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2008-10-09 16:37:31 +00:00
parent 60c71b2230
commit bde9f1ebaa
2 changed files with 56 additions and 85 deletions

View File

@ -1,3 +1,8 @@
2008-10-08 Evi Vanoost <vanooste@rcbi.rochester.edu>
* operation/agentes/estado_grupo.php: Fixed bug #2155213 and rewrote
cleaner HTML partially
2008-10-08 Evi Vanoost <vanooste@rcbi.rochester.edu> 2008-10-08 Evi Vanoost <vanooste@rcbi.rochester.edu>
* godmode/db/db_event.php: Didn't work for some or another reason. * godmode/db/db_event.php: Didn't work for some or another reason.

View File

@ -18,7 +18,7 @@
// Load global vars // Load global vars
require ("include/config.php"); require_once ("include/config.php");
if (! isset($config["show_lastalerts"])) if (! isset($config["show_lastalerts"]))
$config["show_lastalerts"] = 1; $config["show_lastalerts"] = 1;
@ -36,8 +36,8 @@ echo "<h2>".__('Pandora Agents')." &gt; ".__('Group view')."</h2>";
// Made it a subquery, much faster on both the database and server side // Made it a subquery, much faster on both the database and server side
if (isset ($_GET["update_netgroup"])) { if (isset ($_GET["update_netgroup"])) {
if (give_acl ($config['id_user'], $_GET["update_netgroup"], "AW")) { 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"]); $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); process_sql ($sql);
} }
} }
@ -79,8 +79,8 @@ foreach ($groups as $id_group => $group_name) {
AND tagente_modulo.disabled = 0 AND tagente_modulo.disabled = 0
AND tagente_estado.utimestamp != 0", AND tagente_estado.utimestamp != 0",
$id_group); $id_group);
$result = mysql_query ($sql); $result = get_db_all_rows_sql ($sql);
while ($module = mysql_fetch_assoc ($result)) { foreach ($result as $module) {
//if ($config["show_unknown"] > 0) { //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 //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) { if ($total_agents == 0) {
echo "<div class='nf'>".__('There are no defined groups')."</div>"; echo '<div class="nf">'.__('There are no defined groups').'</div>';
if (give_acl ($config['id_user'], 0, "LM") if (give_acl ($config['id_user'], 0, "LM")
|| give_acl ($config['id_user'], 0, "AW") || give_acl ($config['id_user'], 0, "AW")
|| give_acl ($config['id_user'], 0, "PM") || give_acl ($config['id_user'], 0, "PM")
|| give_acl ($config['id_user'], 0, "DM") || give_acl ($config['id_user'], 0, "DM")
|| give_acl ($config['id_user'], 0, "UM")) { || give_acl ($config['id_user'], 0, "UM")) {
echo "&nbsp;<form method='post' action='index.php?sec=gagente&sec2=godmode/groups/configure_group&create_g=1'><input type='submit' class='sub next' name='crt' echo '&nbsp;<form method="post" action="index.php?sec=gagente&sec2=godmode/groups/configure_group&create_g=1">';
value='".__('Create group')."'></form>"; print_submit_button (__('Create group'), 'crt', false, 'class="sub next"');
echo '</form>';
} }
return; return;
} }
$group_size = sizeof ($groups_info); $group_size = sizeof ($groups_info);
$ancho = ceil (sqrt ($group_size + 1)); $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; $real_count = 0;
echo "<table cellpadding=10 cellspacing=10 border=0>"; echo '<table cellpadding="10" cellspacing="10" border="0">';
for ($table = 0; $table < $ancho; $table++) { for ($table = 0; $table < $ancho; $table++) {
if ($real_count >= $group_size) { if ($real_count >= $group_size) {
continue; continue;
} }
echo "<tr class='bot'>"; echo '<tr class="bot">';
//foreach ($groups_info as $group) { //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) { if ($real_count >= $group_size) {
continue; continue;
} }
@ -147,125 +154,84 @@ for ($table = 0; $table < $ancho; $table++) {
$icono_grupo = $group_info["icon"]; $icono_grupo = $group_info["icon"];
$icono_type = ""; $icono_type = "";
if ($group_info["bad"] > 0) { if ($group_info["bad"] > 0) {
$icono_type .= '<img src="images/dot_red.png" $icono_type .= '<img src="images/dot_red.png" title="'.__('Modules bad').'" />';
title="'.__('Modules bad').'">';
} }
if ($group_info["ok"] > 0) { if ($group_info["ok"] > 0) {
$icono_type .= '<img src="images/dot_green.png" $icono_type .= '<img src="images/dot_green.png" title="'.__('Modules OK').'" />';
title="'.__('Modules OK').'">';
} }
// Show yellow light if there are recent alerts fired for this group // Show yellow light if there are recent alerts fired for this group
if ($group_info["alerts"] > 0 ) { if ($group_info["alerts"] > 0 ) {
$icono_type .= '<img src="images/dot_yellow.png" $icono_type .= '<img src="images/dot_yellow.png" title="'.__('Alerts fired').'" />';
title="'.__('Alerts fired').'">';
} }
// Show grey light if there are agent down for this group // Show grey light if there are agent down for this group
if ($group_info["down"] > 0 ) { if ($group_info["down"] > 0 ) {
$icono_type .= '<img src="images/dot_white.png" $icono_type .= '<img src="images/dot_white.png" title="'.__('Agents down').'" />';
title="'.__('Agents down').'">';
} }
// Show red flag is group has disabled alert system // Show red flag is group has disabled alert system
if (give_disabled_group ($group_info["id_group"])) { if (give_disabled_group ($group_info["id_group"])) {
$icono_type .= '<img src="images/flag_red.png" $icono_type .= '<img src="images/flag_red.png" title="'.__('Disabled alerts').'" />';
title="'.__('Disabled alerts').'">';
} }
// By default green border // By default green border
$celda = "<td class='top' style='border: 5px solid #aeff21;' width='100'>"; $celda = '<td class="top" style="border: 5px solid #aeff21;" width="100">';
// Grey border if agent down // Grey border if agent down
if ($config["show_unknown"] > 0) { if ($config["show_unknown"] > 0) {
if ($group_info["down"] > 0) if ($group_info["down"] > 0)
$celda = "<td class='top' style='border: 5px solid #aabbaa;' width='100'>"; $celda = '<td class="top" style="border: 5px solid #aabbaa;" width="100">';
} }
// Yellow border if agents with alerts // Yellow border if agents with alerts
if ($group_info["alerts"] > 0) if ($group_info["alerts"] > 0)
$celda = "<td class='top' style='border: 5px solid #ffea00;' width='100'>"; $celda = '<td class="top" style="border: 5px solid #ffea00;" width="100">';
// Red border if agents bad // Red border if agents bad
if ($group_info["bad"] > 0) if ($group_info["bad"] > 0)
$celda = "<td class='top' style='border: 5px solid #ff0000;' width='100'>"; $celda = '<td class="top" style="border: 5px solid #ff0000;" width="100">';
// Orange if alerts and down modules // Orange if alerts and down modules
if (($group_info["bad"] > 0) && ($group_info["alerts"] > 0)) if (($group_info["bad"] > 0) && ($group_info["alerts"] > 0))
$celda = "<td class='top' style='border: 5px solid #ffbb00;' width='100'>"; $celda = '<td class="top" style="border: 5px solid #ffbb00;" width="100">';
$celda .= "<a href='index.php?sec=estado&amp; $celda .= '<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60&amp;group_id='.$group_info["id_group"].'" class="info">';
sec2=operation/agentes/estado_agente&amp;
refr=60&amp;
group_id=".$group_info["id_group"]."'
class='info'>";
// Add group icon // Add group icon
$celda .= "<img class='top' $celda .= '<img class="top" src="images/groups_small/'.$icono_grupo.'.png" height="32" width="32" alt="" />';
src='images/groups_small/".$icono_grupo.".png' height='32' width='32' alt=''>";
// Add float info table // Add float info table
$celda .= " $celda .= '<span><table cellspacing="2" cellpadding="0" style="margin-left:2px;">
<span> <tr><th colspan="2" width="91">'.__('Agents').':</th></tr>
<table cellspacing='2' cellpadding='0' <tr><td colspan="2" class="datos" align="center"><b>'.$group_info["agent"].'</b></td></tr>
style='margin-left:2px;'> </table>
<tr><th colspan='2' width='91'>". <table cellspacing="2" cellpadding="0" style="margin-left:2px">
__('Agents').": </th></tr> <tr><th colspan="2" width="90">'.__('Monitors').':</th></tr>
<tr><td colspan='2' class='datos' align='center'><b>". <tr><td class="datos"><img src="images/b_green.png" align="top" alt="" />'.__('Ok').':</td>
$group_info["agent"]."</b></td></tr> <td class="datos"><font class="greenb">'.$group_info["ok"].'</font></td></tr>
</table> <tr><td class="datos"><img src="images/b_red.png" align="top" alt="" />'.__('Fail').':</td>
<table cellspacing='2' cellpadding='0' <td class="datos"><font class="redb">'.$group_info["bad"].'</font></td></tr>';
style='margin-left:2px'>
<tr>
<th colspan='2' width='90'>".
ucfirst (__('Monitors')).":</th>
</tr>
<tr>
<td class='datos'>
<img src='images/b_green.png' align='top' alt='' >
".__('ok').": </td>
<td class='datos'>
<font class='greenb'>".$group_info["ok"]."</font>
</td>
</tr>
<tr>
<td class='datos'>
<img src='images/b_red.png' align='top' alt=''>
".__('Fail').": </td>
<td class='datos'><font class='redb'>".
$group_info["bad"]."</font></td>
</tr>";
if ($config["show_unknown"] > 0) { if ($config["show_unknown"] > 0) {
$celda .= " $celda .= '<tr><td class="datos"><img src="images/b_white.png" align="top" alt="" />'.__('Down').':</td>
<tr> <td class="datos"><font class="redb">'.$group_info["down"].'</font></td></tr>';
<td class='datos'>
<img src='images/b_white.png' align='top' alt=''>
".__('Down').": </td>
<td class='datos'><font class='redb'>".
$group_info["down"]."</font></td></tr>";
} }
if ($config["show_lastalerts"] == 1) if ($config["show_lastalerts"] == 1)
$celda .= "<tr> $celda .= '<tr><td class="datos"><img src="images/b_yellow.png" align="top" alt="" />'.__('Alerts').':</td>
<td class='datos'> <td class="datos"><font class="grey">'.$group_info["alerts"].'</font></td></tr>';
<img src='images/b_yellow.png' align='top' alt=''>
".__('Alerts').": </td>
<td class='datos'><font class='grey'>".
$group_info["alerts"]."</font></td>
</tr>";
$celda .= "</table></span></a>"; $celda .= "</table></span></a>";
// Render network exec module button, only when this group is writtable by user // Render network exec module button, only when this group is writtable by user
if (give_acl ($config['id_user'], $group_info["id_group"], "AW")) { if (give_acl ($config['id_user'], $group_info["id_group"], "AW")) {
$celda .= "&nbsp;<a href='index.php? $celda .= '&nbsp;<a href="index.php?sec=estado&sec2=operation/agentes/estado_grupo&update_netgroup='.$group_info["id_group"].'"><img src="images/target.png" /></a>';
sec=estado&
sec2=operation/agentes/estado_grupo&
update_netgroup=".$group_info["id_group"]."'>
<img src='images/target.png'></a>";
} }
$celda .= "<br><br>".
$icono_type."<br><br> $celda .= '<br /><br />'.$icono_type.'<br /><br /><span class="gr">'.$group_name.'</span>';
<span class='gr'>".$group_name."</span>";
echo $celda; echo $celda;
$real_count++; $real_count++;
} }