From 0c36881c3e485e0c364dc348756a3b146ee4f8ab Mon Sep 17 00:00:00 2001 From: ramonn <noreply@pandorafms.org> Date: Wed, 17 Jul 2013 17:39:27 +0000 Subject: [PATCH] 2013-07-17 Ramon Novoa <rnovoa@artica.es> * extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, godmode/snmpconsole/snmp_alert.php, pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql: Added support for SNMP alert ordering. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8540 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 +++ .../pandoradb_migrate_4.0.x_to_5.0.mysql.sql | 1 + .../pandoradb_migrate_4.0.x_to_5.0.oracle.sql | 1 + ...doradb_migrate_4.0.x_to_5.0.postgreSQL.sql | 1 + .../godmode/snmpconsole/snmp_alert.php | 70 +++++++++++-------- pandora_console/pandoradb.oracle.sql | 3 +- pandora_console/pandoradb.postgreSQL.sql | 3 +- pandora_console/pandoradb.sql | 1 + 8 files changed, 59 insertions(+), 31 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 26d7bc9974..9ed027775b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-07-17 Ramon Novoa <rnovoa@artica.es> + + * extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, + godmode/snmpconsole/snmp_alert.php, + pandoradb.sql, + pandoradb.postgreSQL.sql, + pandoradb.oracle.sql: Added support for SNMP alert ordering. + 2013-07-17 Sergio Martin <sergio.martin@artica.es> * include/functions_users.php diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql index 2bdf6298d9..f2b7e180df 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql @@ -166,6 +166,7 @@ ALTER TABLE `talert_snmp` ADD COLUMN `_snmp_f7_` text NOT NULL; ALTER TABLE `talert_snmp` ADD COLUMN `_snmp_f8_` text NOT NULL; ALTER TABLE `talert_snmp` ADD COLUMN `_snmp_f9_` text NOT NULL; ALTER TABLE `talert_snmp` ADD COLUMN `_snmp_f10_` text NOT NULL; +ALTER TABLE `talert_snmp` ADD COLUMN `position` int(10) UNSIGNED NOT NULL DEFAULT '0'; -- ---------------------------------------------------------------------- -- Table `tagente_modulo` diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql index 3be27c4ef8..4e2018df13 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql @@ -198,6 +198,7 @@ ALTER TABLE talert_snmp ADD (al_field8 CLOB default ''); ALTER TABLE talert_snmp ADD (al_field9 CLOB default ''); ALTER TABLE talert_snmp ADD (al_field10 CLOB default ''); ALTER TABLE talert_snmp ADD (al_field10 CLOB default ''); +ALTER TABLE talert_snmp ADD (position NUMBER(10, 0) default 0 NOT NULL); -- --------------------------------------------------------------------- -- Table tevent_filter diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql index 22257dce8f..5848350386 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql @@ -189,6 +189,7 @@ ALTER TABLE "talert_snmp" ADD COLUMN "al_field7" text NOT NULL default ''; ALTER TABLE "talert_snmp" ADD COLUMN "al_field8" text NOT NULL default ''; ALTER TABLE "talert_snmp" ADD COLUMN "al_field9" text NOT NULL default ''; ALTER TABLE "talert_snmp" ADD COLUMN "al_field10" text NOT NULL default ''; +ALTER TABLE "talert_snmp" ADD COLUMN "position" INTEGER NOT NULL default 0; -- ----------------------------------------------------- -- Table "tagente_modulo" diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 87c01c72e3..bb7ab03823 100644 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -70,6 +70,7 @@ else if (isset ($_GET["submit"])) { $custom_oid_data_10 = (string) get_parameter ("custom_oid_data_10"); $trap_type = (int) get_parameter ("trap_type", -1); $single_value = (string) get_parameter ("single_value"); + $position = (int) get_parameter ("position"); if ($time_threshold == -1) { $time_threshold = $time_other; @@ -107,7 +108,8 @@ else if (isset ($_GET["submit"])) { '_snmp_f9_' => $custom_oid_data_9, '_snmp_f10_' => $custom_oid_data_10, 'trap_type' => $trap_type, - 'single_value' => $single_value); + 'single_value' => $single_value, + 'position' => $position); $result = db_process_sql_insert('talert_snmp', $values); @@ -133,7 +135,8 @@ else if (isset ($_GET["submit"])) { _snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s', _snmp_f4_ = '%s', _snmp_f5_ = '%s', _snmp_f6_ = '%s', _snmp_f7_ = '%s', _snmp_f8_ = '%s', _snmp_f9_ = '%s', - _snmp_f10_ = '%s', trap_type = %d, single_value = '%s' + _snmp_f10_ = '%s', trap_type = %d, single_value = '%s', + position = '%s' WHERE id_as = %d", $priority, $alert_type, $al_field1, $al_field2, $al_field3, $al_field4, $al_field5, $al_field6, $al_field7, $al_field8, @@ -142,7 +145,7 @@ else if (isset ($_GET["submit"])) { $max_alerts, $min_alerts, $custom_oid_data_1, $custom_oid_data_2, $custom_oid_data_3, $custom_oid_data_4, $custom_oid_data_5, $custom_oid_data_6, $custom_oid_data_7, $custom_oid_data_8, - $custom_oid_data_9, $custom_oid_data_10, $trap_type, $single_value, $id_as); + $custom_oid_data_9, $custom_oid_data_10, $trap_type, $single_value, $position, $id_as); $result = db_process_sql ($sql); @@ -197,6 +200,7 @@ if ((isset ($_GET["update_alert"])) && ($_GET["update_alert"] != -1)) { $custom_oid_data_10 = $alert["_snmp_f10_"]; $trap_type = $alert["trap_type"]; $single_value = $alert["single_value"]; + $position = $alert["position"]; } elseif (isset ($_GET["update_alert"])) { // Variable init @@ -232,6 +236,7 @@ elseif (isset ($_GET["update_alert"])) { $custom_oid_data_10 = ''; $trap_type = -1; $single_value = ''; + $position = 0; } // Header @@ -459,7 +464,9 @@ if (isset ($_GET["update_alert"])) { break; } echo '</td></tr>'; - + echo '<tr><td class="datos">'.__('Position').'</td><td class="datos">'; + html_print_input_text ("position", $position, '', 3); + echo '</td></tr>'; echo '</table>'; echo "<table style='width:98%'>"; @@ -493,52 +500,57 @@ else { $table->class= "databox"; $table->align = array (); - $table->head[0] = __('Alert action'); + $table->head[0] = '<span title="' . __('Position') . '">' . __('P.') . '</span>'; + $table->align[0] = 'center'; + + $table->head[1] = __('Alert action'); - $table->head[1] = __('SNMP Agent'); - $table->size[1] = "90px"; - $table->align[1] = 'center'; - - $table->head[2] = __('OID'); + $table->head[2] = __('SNMP Agent'); + $table->size[2] = "90px"; $table->align[2] = 'center'; - $table->head[3] = __('Custom Value/OID'); + $table->head[3] = __('OID'); $table->align[3] = 'center'; - $table->head[4] = __('Description'); + $table->head[4] = __('Custom Value/OID'); + $table->align[4] = 'center'; - $table->head[5] = __('Times fired'); - $table->align[5] = 'center'; + $table->head[5] = __('Description'); - $table->head[6] = __('Last fired'); + $table->head[6] = __('Times fired'); $table->align[6] = 'center'; - $table->head[7] = __('Action'); - $table->size[7] = "50px"; + $table->head[7] = __('Last fired'); $table->align[7] = 'center'; + $table->head[8] = __('Action'); + $table->size[8] = "50px"; + $table->align[8] = 'center'; + foreach ($result as $row) { $data = array (); - $data[0] = '<a href="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&update_alert='.$row["id_as"].'">' . alerts_get_alert_action_name ($row["id_alert"]) . '</a>'; + $data[0] = $row["position"]; - $data[1] = __('SNMP Agent'); - $data[1] = $row["agent"]; - $data[2] = __('OID'); - $data[2] = $row["oid"]; - $data[3] = __('Custom Value/OID'); - $data[3] = $row["custom_oid"]; + $data[1] = '<a href="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&update_alert='.$row["id_as"].'">' . alerts_get_alert_action_name ($row["id_alert"]) . '</a>'; - $data[4] = $row["description"]; - $data[5] = $row["times_fired"]; + $data[2] = __('SNMP Agent'); + $data[2] = $row["agent"]; + $data[3] = __('OID'); + $data[3] = $row["oid"]; + $data[4] = __('Custom Value/OID'); + $data[4] = $row["custom_oid"]; + + $data[5] = $row["description"]; + $data[6] = $row["times_fired"]; if (($row["last_fired"] != "1970-01-01 00:00:00") and ($row["last_fired"] != "01-01-1970 00:00:00")) { - $data[6] = ui_print_timestamp($row["last_fired"], true); + $data[7] = ui_print_timestamp($row["last_fired"], true); } else { - $data[6] = __('Never'); + $data[7] = __('Never'); } - $data[7] = '<a href="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&update_alert='.$row["id_as"].'">' . + $data[8] = '<a href="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&update_alert='.$row["id_as"].'">' . html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '</a>' . ' <a href="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&delete_alert='.$row["id_as"].'">' . html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . '</a>'; diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 4ed750d2ef..ff496f7557 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -302,7 +302,8 @@ CREATE TABLE talert_snmp ( _snmp_f9_ CLOB default '', _snmp_f10_ CLOB default '', trap_type NUMBER(10, 0) DEFAULT -1 NOT NULL, - single_value VARCHAR2(255) DEFAULT '' + single_value VARCHAR2(255) DEFAULT '', + "position" NUMBER(10, 0) default 0 NOT NULL ); CREATE SEQUENCE talert_snmp_s INCREMENT BY 1 START WITH 1; diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index 7a6c85d0cf..87a91d6e5c 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -286,7 +286,8 @@ CREATE TABLE "talert_snmp" ( "_snmp_f9_" text DEFAULT '', "_snmp_f10_" text DEFAULT '', "trap_type" INTEGER NOT NULL DEFAULT '-1', - "single_value" varchar(255) DEFAULT '' + "single_value" varchar(255) DEFAULT '', + "position" INTEGER NOT NULL default 0 ); CREATE TABLE "talert_commands" ( diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f457ae0d93..a90314880f 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -293,6 +293,7 @@ CREATE TABLE IF NOT EXISTS `talert_snmp` ( `_snmp_f10_` text, `trap_type` int(11) NOT NULL default '-1', `single_value` varchar(255) default '', + `position` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`id_as`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;