2008-12-03 Raul Mateos <raulofpandora@gmail.com>

* include/functions_db.php: Now if no event, table shows "no event" text.
	Cosmetic table header change.
	* operation/agentes/tactical.php: Solve warning if no servers defined.
	Cosmetic table header change.
	* operation/events/events.php: Change "error" class to "not found" class.

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1280 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
raulmateos 2008-12-03 12:41:09 +00:00
parent 6cd25af0f7
commit 9c35f1d841
4 changed files with 142 additions and 109 deletions

View File

@ -1,3 +1,13 @@
2008-12-03 Raul Mateos <raulofpandora@gmail.com>
* include/functions_db.php: Now if no event, table shows "no event" text.
Cosmetic table header change.
* operation/agentes/tactical.php: Solve warning if no servers defined.
Cosmetic table header change.
* operation/events/events.php: Change "error" class to "not found" class.
2008-12-02 Jorge Gonzalez <jorgegonz@artica.es>
* include/languages/index.pot: Updated Spanish translation.

View File

@ -2125,100 +2125,113 @@ function show_alert_row_mini ($id_combined_alert) {
*/
function smal_event_table ($filter = "", $limit = 10, $width = 440) {
global $config;
$sql = sprintf ("SELECT * FROM tevento %s ORDER BY timestamp DESC LIMIT %d",$filter,$limit);
echo "<table cellpadding='4' cellspacing='4' width='$width' border=0 class='databox'>";
echo "<tr>";
echo "<th colspan=6>".__('Latest events')."</th>";
echo "<tr>";
echo "<th class='datos3 f9'>".__('St')."</th>";
echo "<th class='datos3 f9'>".__('Type')."</th>";
echo "<th class='datos3 f9'>".__('Event name')."</th>";
echo "<th class='datos3 f9'>".__('Agent name')."</th>";
echo "<th class='datos3 f9'>".__('User ID')."</th>";
echo "<th class='datos3 f9'>".__('Timestamp')."</th>";
$sql = sprintf ("SELECT * FROM tevento %s
ORDER BY timestamp DESC LIMIT %d",
$filter, $limit);
$result = get_db_all_rows_sql ($sql);
if($result === false)
$result = array();
foreach ($result as $event) {
$id_grupo = $event["id_grupo"];
if (! give_acl ($config["id_user"], $id_grupo, "AR")) {
continue;
}
/* Only incident read access to view data ! */
$tdclass = get_priority_class ($event["criticity"]);
$criticity_label = get_priority_name ($event["criticity"]);
/* Colored box */
echo "<tr><td class='$tdclass' title='$criticity_label' align='center'>";
if ($event["estado"] == 0) {
echo "<img src='images/pixel_red.png' width=20 height=20>";
} else {
echo "<img src='images/pixel_green.png' width=20 height=20>";
}
/* Event type */
echo "<td class='".$tdclass."' title='".$event["event_type"]."'>";
switch ($event["event_type"]) {
case "unknown":
echo "<img src='images/err.png'>";
break;
case "alert_recovered":
echo "<img src='images/error.png'>";
break;
case "alert_manual_validation":
echo "<img src='images/eye.png'>";
break;
case "monitor_up":
echo "<img src='images/lightbulb.png'>";
break;
case "monitor_down":
echo "<img src='images/lightbulb_off.png'>";
break;
case "alert_fired":
echo "<img src='images/bell.png'>";
break;
case "system";
echo "<img src='images/cog.png'>";
break;
case "recon_host_detected";
echo "<img src='images/network.png'>";
break;
}
// Event description
echo "<td class='".$tdclass."f9' title='".$event["evento"]."'>";
echo substr ($event["evento"],0,45);
if (strlen ($event["evento"]) > 45) {
echo "..";
}
if ($event["id_agente"] > 0) {
// Agent name
$agent_name = dame_nombre_agente ($event["id_agente"]);
echo "<td class='".$tdclass."f9' title='$agent_name'><a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event["id_agente"]."'><b>";
echo substr ($agent_name, 0, 14);
if (strlen ($agent_name) > 14)
echo "..";
echo "</b></a>";
// for System or SNMP generated alerts
} else {
if ($event["event_type"] == "system") {
echo "<td class='$tdclass'>".__('System');
} else {
echo "<td class='$tdclass'>".__('Alert')."SNMP";
if ($result === false) {
$result = array ();
echo '<div class="nf">'.__('No events').'</div>';
} else {
echo "<table cellpadding='4' cellspacing='4' width='$width' border=0 class='databox'>";
echo "<tr>";
echo "<th colspan='6' style='background-color:#799E48'>".__('Latest events')."</th>";
echo "<tr>";
echo "<th class='datos3 f9'>".__('St')."</th>";
echo "<th class='datos3 f9'>".__('Type')."</th>";
echo "<th class='datos3 f9'>".__('Event name')."</th>";
echo "<th class='datos3 f9'>".__('Agent name')."</th>";
echo "<th class='datos3 f9'>".__('User ID')."</th>";
echo "<th class='datos3 f9'>".__('Timestamp')."</th>";
foreach ($result as $event) {
$id_grupo = $event["id_grupo"];
if (! give_acl ($config["id_user"], $id_grupo, "AR")) {
continue;
}
/* Only incident read access to view data ! */
$tdclass = get_priority_class ($event["criticity"]);
$criticity_label = get_priority_name ($event["criticity"]);
/* Colored box */
echo "<tr>";
echo "<td class='$tdclass' title='$criticity_label' align='center'>";
if ($event["estado"] == 0) {
echo "<img src='images/pixel_red.png' width=20 height=20>";
} else {
echo "<img src='images/pixel_green.png' width=20 height=20>";
}
echo "</td>";
/* Event type */
echo "<td class='".$tdclass."' title='".$event["event_type"]."'>";
switch ($event["event_type"]) {
case "unknown":
echo "<img src='images/err.png'>";
break;
case "alert_recovered":
echo "<img src='images/error.png'>";
break;
case "alert_manual_validation":
echo "<img src='images/eye.png'>";
break;
case "monitor_up":
echo "<img src='images/lightbulb.png'>";
break;
case "monitor_down":
echo "<img src='images/lightbulb_off.png'>";
break;
case "alert_fired":
echo "<img src='images/bell.png'>";
break;
case "system";
echo "<img src='images/cog.png'>";
break;
case "recon_host_detected";
echo "<img src='images/network.png'>";
break;
}
echo "</td>";
// Event description
echo "<td class='".$tdclass."f9' title='".$event["evento"]."'>";
echo substr ($event["evento"],0,45);
if (strlen ($event["evento"]) > 45) {
echo "..";
}
echo "</td>";
if ($event["id_agente"] > 0) {
// Agent name
$agent_name = dame_nombre_agente ($event["id_agente"]);
echo "<td class='".$tdclass."f9' title='$agent_name'><a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event["id_agente"]."'><b>";
echo substr ($agent_name, 0, 14);
if (strlen ($agent_name) > 14)
echo "..";
echo "</b></a>";
echo "</td>";
// for System or SNMP generated alerts
} else {
if ($event["event_type"] == "system") {
echo "<td class='$tdclass'>".__('System')."</td>";
} else {
echo "<td class='$tdclass'>".__('Alert')."SNMP</td>";
}
}
// User who validated event
echo "<td class='$tdclass'>";
if ($event["estado"] != 0) {
echo "<a href='index.php?sec=usuario&sec2=operation/users/user_edit&ver=".$event["id_usuario"]."'>".substr ($event["id_usuario"],0,8)."<a href='#' class='tip'> <span>".dame_nombre_real ($event["id_usuario"])."</span></a></a>";
}
echo "</td>";
// Timestamp
echo "<td class='".$tdclass."f9' title='".$event["timestamp"]."'>";
echo human_time_comparation ($event["timestamp"]);
echo "</td>";
echo "</tr>";
}
// User who validated event
echo "<td class='$tdclass'>";
if ($event["estado"] != 0) {
echo "<a href='index.php?sec=usuario&sec2=operation/users/user_edit&ver=".$event["id_usuario"]."'>".substr ($event["id_usuario"],0,8)."<a href='#' class='tip'> <span>".dame_nombre_real ($event["id_usuario"])."</span></a></a>";
}
// Timestamp
echo "<td class='".$tdclass."f9' title='".$event["timestamp"]."'>";
echo human_time_comparation ($event["timestamp"]);
echo "</table>";
}
echo "</table>";
}

View File

@ -1,14 +1,14 @@
<?php
// Pandora FMS - The Flexible Monitoring System
// Pandora FMS - the Flexible Monitoring System
// ============================================
// Copyright (c) 2004-2008 Sancho Lerena, slerena@gmail.com
// Copyright (c) 2005-2008 Artica Soluciones Tecnologicas, info@artica.es
// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
// Please see http://pandora.sourceforge.net for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// modify it under the terms of the GNU Lesser General Public License (LGPL)
// as published by the Free Software Foundation for version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ -203,15 +203,25 @@ echo '<div style="width: 450px; float:left;" id="rightcolumn">';
// Server information
echo '<table class="databox" cellpadding="4" cellspacing="4" style="width:100%;">';
echo '<thead><tr><th colspan="4">'.__('Tactical server information').'</th></tr>';
echo '<tr><th style="font-weight:none;">'.__('Name').'</th><th style="font-weight:none;">'.__('Status').'</th><th style="font-weight:none;">'.__('Load').'</th><th style="font-weight:none;">'.__('Lag').pandora_help ("serverlag", true).'</th></tr></thead><tbody>';
$serverinfo = get_server_info ();
$total_modules = get_agentmodule_count ();
$cells = array ();
foreach ($serverinfo as $server_id => $server_info) {
if ($serverinfo) {
echo '<table class="databox" cellpadding="4" cellspacing="4" style="width:100%;">';
echo '<thead>
<tr>
<th colspan="4" style="background-color:#799E48">'.__('Tactical server information').'</th>
</tr>';
echo '<tr>
<th style="font-weight:none;">'.__('Name').'</th>
<th style="font-weight:none;">'.__('Status').'</th>
<th style="font-weight:none;">'.__('Load').'</th>
<th style="font-weight:none;">'.__('Lag').pandora_help ("serverlag", true).'</th>
</tr></thead><tbody>';
foreach ($serverinfo as $server_id => $server_info) {
$data = array ();
$data[0] = $server_info["name"];
@ -220,8 +230,8 @@ foreach ($serverinfo as $server_id => $server_info) {
} else {
$data[1] = '<img src="images/pixel_green.png" width="20" height="20" />';
}
if ($server_info["modules"] > 0 && $total_modules > 0) {
$percent = $server_info["modules"] / ($total_modules / 100);
} else {
@ -232,9 +242,9 @@ foreach ($serverinfo as $server_id => $server_info) {
$data[3] = $server_info["lag"]." / ".$server_info["module_lag"];
array_push ($cells, $data);
}
}
foreach ($cells as $key => $row) {
foreach ($cells as $key => $row) {
//Switch class around
$class = (($key % 2) ? "datos2" : "datos");
echo '<tr>
@ -242,10 +252,10 @@ foreach ($cells as $key => $row) {
<td class="'.$class.'" style="text-align:center;">'.$row[1].'</td>
<td class="'.$class.'" style="text-align:center;">'.$row[2].'</td>
<td class="'.$class.'" style="text-align:right;">'.$row[3].'</td>
</tr>';
</tr>';
}
echo '</tbody></table>';
}
echo '</tbody></table>';
smal_event_table ("", 10, 450);
echo '</div>';

View File

@ -388,7 +388,7 @@ if (!empty ($table->data)) {
}
echo '</div></form>';
} else {
echo '<div class="error">'.__('No events').'</div>';
echo '<div class="nf">'.__('No events').'</div>';
}
unset ($table);