From 3ae0fbb1c017ce7deabb6d6c9c0b836059af814f Mon Sep 17 00:00:00 2001
From: guruevi <noreply@pandorafms.org>
Date: Wed, 22 Oct 2008 15:05:15 +0000
Subject: [PATCH] 2008-10-22  Evi Vanoost  <vanooste@rcbi.rochester.edu>

        * operation/snmpconsole/snmp_view.php: Feature request #2166257

        * pandoradb.sql: Feature request #2166257

	* bin/pandora_snmpconsole: Feature request #2166257

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1189 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                     |  6 +++
 .../operation/snmpconsole/snmp_view.php       | 46 +++++++++++++++++--
 pandora_console/pandoradb.sql                 |  1 +
 pandora_server/ChangeLog                      |  4 ++
 pandora_server/bin/pandora_snmpconsole        |  2 +-
 5 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index d5d953aea9..879def7aea 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -14,6 +14,12 @@
           godmode/servers/modificar_server.php: Updated translation
           infrastructure.
 
+2008-10-22  Evi Vanoost  <vanooste@rcbi.rochester.edu>
+
+	* operation/snmpconsole/snmp_view.php: Feature request #2166257
+
+	* pandoradb.sql: Feature request #2166257
+
 2008-10-22  Evi Vanoost  <vanooste@rcbi.rochester.edu>
 
 	* operation/snmpconsole/snmp_view.php: Style update and uses new
diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php
index 5b81bc0a81..ed0081e16d 100644
--- a/pandora_console/operation/snmpconsole/snmp_view.php
+++ b/pandora_console/operation/snmpconsole/snmp_view.php
@@ -106,7 +106,9 @@ echo '<img src="images/pixel_green.png" width="20" height="20" /> - '.__('Valida
 echo '<br />';
 echo '<img src="images/pixel_red.png" width="20" height="20" /> - '.__('Not validated event');
 echo '</td><td class="f9" style="padding-left: 30px;">';
-echo '<img src="images/pixel_yellow.png" width="20" height="20" /> - '.__('Alert fired');
+echo '<img src="images/pixel_yellow.png" width="40" height="20" /> - '.__('Alert fired');
+echo '<br />';
+echo '<img src="images/pixel_gray.png" width="40" height="20" /> - '.__('Alert not fired');
 echo '</td><td class="f9" style="padding-left: 30px;">';
 echo '<img src="images/ok.png" /> - '.__('Validate event');
 echo '<br />'; 
@@ -128,21 +130,38 @@ $table->class = "databox";
 $table->head = array ();
 $table->size = array ();
 $table->data = array ();
+$table->align = array ();
 
 $table->head[0] = __('Status');
+$table->align[0] = "center";
+
 $table->head[1] = __('SNMP Agent');
+$table->align[1] = "center";
+
 $table->head[2] = __('OID');
+$table->align[2] = "center";
+
 $table->head[3] = __('Value');
+$table->align[3] = "center";
+
 $table->head[4] = __('Custom');
+$table->align[4] = "center";
+
 $table->head[5] = __('User ID');
+$table->align[5] = "center";
 
 $table->head[6] = __('Timestamp');
 $table->size[6] = 130;
+$table->align[6] = "center";
 
 $table->head[7] = __('Alert');
+$table->align[7] = "center";
+
 $table->head[8] = __('Action');
+$table->align[8] = "center";
 
 $table->head[9] = print_checkbox_extended ("allbox", 1, false, false, "javascript:CheckAll();", 'class="chk" title="'.__('All').'"', true);
+$table->align[9] = "center";
 
 // Skip offset records
 foreach ($traps as $trap) {
@@ -209,9 +228,30 @@ foreach ($traps as $trap) {
 
 	//Alert fired
 	if (!empty ($trap["alerted"])) {
-		$data[7] = '<img src="images/pixel_yellow.png" width="40" height="18" border="0" title="'.__('Alert fired').'" />';
+		$idx = count ($table->data);
+		switch ($trap["priority"]) {
+		case 0:
+			$table->rowclass[$idx] = "datos_blue";
+			break;
+		case 1:
+			$table->rowclass[$idx] = "datos_grey";
+			break;
+		case 2:
+			$table->rowclass[$idx] = "datos_green";
+			break;
+		case 3:
+			$table->rowclass[$idx] = "datos_yellow";
+			break;
+		case 4:
+			$table->rowclass[$idx] = "datos_red";
+			break;
+		default:
+			$table->rowclass[$idx] = "datos_grey";
+		}
+
+		$data[7] = '<img src="images/pixel_yellow.png" width="40" height="20" border="0" title="'.__('Alert fired').'" />';
 	} else {
-		$data[7] = '--';
+		$data[7] = '<img src="images/pixel_gray.png" width="40" height="20" border="0" title="'.__('Alert not fired').'" />';
 	}
 
 	//Actions
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index e20737e74c..5bf58df765 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -535,6 +535,7 @@ CREATE TABLE IF NOT EXISTS `ttrap` (
   `status` smallint(6) NOT NULL default '0',
   `id_usuario` varchar(150) default '',
   `timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
+  `priority` tinyint(4) unsigned NOT NULL default '2',
   PRIMARY KEY  (`id_trap`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog
index 1e870556a5..afecfa3153 100644
--- a/pandora_server/ChangeLog
+++ b/pandora_server/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-22  Evi Vanoost  <vanooste@rcbi.rochester.edu>
+
+	* bin/pandora_snmpconsole: Feature request #2166257
+
 2008-10-20  Esteban Sanchez  <estebans@artica.es>
 
 	* lib/PandoraFMS/DB.pm: Fixed a strange bug that was causing to
diff --git a/pandora_server/bin/pandora_snmpconsole b/pandora_server/bin/pandora_snmpconsole
index d72802878c..aa467afdb8 100755
--- a/pandora_server/bin/pandora_snmpconsole
+++ b/pandora_server/bin/pandora_snmpconsole
@@ -289,7 +289,7 @@ sub calcula_alerta_snmp {
 					# Due DBI doesnt return ID of a new inserted item, we now need to find ourselves 
 					# this is a crap :(
 
-					my $query_idag3 = "update ttrap set alerted = 1 where timestamp = '$timestamp' and source = '$trap_agente'";
+					my $query_idag3 = "update ttrap set alerted = 1, priority = $alert_priority where timestamp = '$timestamp' and source = '$trap_agente'";
 					$dbh->do($query_idag3);
 
 				} else { # Alert is in valid timegap but has too many alerts or too many little