From 454db840e5b016283bc8e9c4d0df38192a79a47d Mon Sep 17 00:00:00 2001 From: ramonn Date: Wed, 10 Jul 2013 16:49:05 +0000 Subject: [PATCH] 2013-07-10 Ramon Novoa * 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, operation/snmpconsole/snmp_view.php: Added support to filter 10 binding vars. Added binding var automatic translation and other small improvements. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8511 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 +++++ .../pandoradb_migrate_4.0.x_to_5.0.mysql.sql | 10 +++- .../pandoradb_migrate_4.0.x_to_5.0.oracle.sql | 5 ++ ...doradb_migrate_4.0.x_to_5.0.postgreSQL.sql | 4 ++ .../godmode/snmpconsole/snmp_alert.php | 48 +++++++++++++++++-- .../operation/snmpconsole/snmp_view.php | 21 +++++--- pandora_console/pandoradb.oracle.sql | 4 ++ pandora_console/pandoradb.postgreSQL.sql | 4 ++ pandora_console/pandoradb.sql | 7 ++- 9 files changed, 105 insertions(+), 11 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5d24286060..88a1fa7a43 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2013-07-10 Ramon Novoa + + * 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, + operation/snmpconsole/snmp_view.php: Added support to filter 10 + binding vars. Added binding var automatic translation and other + small improvements. + 2013-07-10 Miguel de Dios * mobile/operation/agents.php: fixed lost semicolon. 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 f14276209a..2bdf6298d9 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 @@ -151,7 +151,9 @@ ALTER TABLE `tgrupo` ADD COLUMN `other` text; -- Table `talert_snmp` -- ---------------------------------------------------------------------- ALTER TABLE `talert_snmp` ADD COLUMN (`_snmp_f1_` text, `_snmp_f2_` text, `_snmp_f3_` text, - `_snmp_f4_` text, `_snmp_f5_` text, `_snmp_f6_` text, `trap_type` int(11) NOT NULL default '-1', + `_snmp_f4_` text, `_snmp_f5_` text, `_snmp_f6_` text, + `_snmp_f7_` text, `_snmp_f8_` text, `_snmp_f9_` text, + `_snmp_f10_` text, `trap_type` int(11) NOT NULL default '-1', `single_value` varchar(255) DEFAULT ''); ALTER TABLE `talert_snmp` ADD COLUMN `al_field4` text NOT NULL; ALTER TABLE `talert_snmp` ADD COLUMN `al_field5` text NOT NULL; @@ -160,6 +162,10 @@ ALTER TABLE `talert_snmp` ADD COLUMN `al_field7` text NOT NULL; ALTER TABLE `talert_snmp` ADD COLUMN `al_field8` text NOT NULL; ALTER TABLE `talert_snmp` ADD COLUMN `al_field9` text NOT NULL; ALTER TABLE `talert_snmp` ADD COLUMN `al_field10` text NOT NULL; +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; -- ---------------------------------------------------------------------- -- Table `tagente_modulo` @@ -1108,6 +1114,8 @@ ALTER TABLE tevento ADD INDEX `idx_utimestamp` USING BTREE (`utimestamp`); ALTER TABLE tserver DROP INDEX keepalive; ALTER TABLE tserver DROP INDEX status; +ALTER TABLE ttrap ADD INDEX `source` USING BTREE (`source`); + -- --------------------------------------------------------------------- -- Adapt the talert commands to new macro system -- --------------------------------------------------------------------- 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 3d077488db..3be27c4ef8 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 @@ -184,6 +184,10 @@ ALTER TABLE talert_snmp ADD (_snmp_f3_ CLOB default ''); ALTER TABLE talert_snmp ADD (_snmp_f4_ CLOB default ''); ALTER TABLE talert_snmp ADD (_snmp_f5_ CLOB default ''); ALTER TABLE talert_snmp ADD (_snmp_f6_ CLOB default ''); +ALTER TABLE talert_snmp ADD (_snmp_f7_ CLOB default ''); +ALTER TABLE talert_snmp ADD (_snmp_f8_ CLOB default ''); +ALTER TABLE talert_snmp ADD (_snmp_f9_ CLOB default ''); +ALTER TABLE talert_snmp ADD (_snmp_f10_ CLOB default ''); ALTER TABLE talert_snmp ADD (trap_type NUMBER(10, 0) DEFAULT -1 NOT NULL); ALTER TABLE talert_snmp ADD (single_value VARCHAR2(255) DEFAULT ''); ALTER TABLE talert_snmp ADD (al_field4 CLOB default ''); @@ -193,6 +197,7 @@ ALTER TABLE talert_snmp ADD (al_field7 CLOB default ''); 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 ''); -- --------------------------------------------------------------------- -- 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 d6f85789bb..22257dce8f 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 @@ -176,6 +176,10 @@ ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f3_" text DEFAULT ''; ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f4_" text DEFAULT ''; ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f5_" text DEFAULT ''; ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f6_" text DEFAULT ''; +ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f7_" text DEFAULT ''; +ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f8_" text DEFAULT ''; +ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f9_" text DEFAULT ''; +ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f10_" text DEFAULT ''; ALTER TABLE "talert_snmp" ADD COLUMN "trap_type" INTEGER NOT NULL DEFAULT '-1'; ALTER TABLE "talert_snmp" ADD COLUMN "single_value" varchar(255) DEFAULT ''; ALTER TABLE "talert_snmp" ADD COLUMN "al_field4" text NOT NULL default ''; diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 6f01aafd8a..87c01c72e3 100644 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -64,6 +64,10 @@ else if (isset ($_GET["submit"])) { $custom_oid_data_4 = (string) get_parameter ("custom_oid_data_4"); $custom_oid_data_5 = (string) get_parameter ("custom_oid_data_5"); $custom_oid_data_6 = (string) get_parameter ("custom_oid_data_6"); + $custom_oid_data_7 = (string) get_parameter ("custom_oid_data_7"); + $custom_oid_data_8 = (string) get_parameter ("custom_oid_data_8"); + $custom_oid_data_9 = (string) get_parameter ("custom_oid_data_9"); + $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"); @@ -98,6 +102,10 @@ else if (isset ($_GET["submit"])) { '_snmp_f4_' => $custom_oid_data_4, '_snmp_f5_' => $custom_oid_data_5, '_snmp_f6_' => $custom_oid_data_6, + '_snmp_f7_' => $custom_oid_data_7, + '_snmp_f8_' => $custom_oid_data_8, + '_snmp_f9_' => $custom_oid_data_9, + '_snmp_f10_' => $custom_oid_data_10, 'trap_type' => $trap_type, 'single_value' => $single_value); @@ -124,7 +132,8 @@ else if (isset ($_GET["submit"])) { time_threshold = %d, max_alerts = %d, min_alerts = %d, _snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s', _snmp_f4_ = '%s', _snmp_f5_ = '%s', _snmp_f6_ = '%s', - trap_type = %d, single_value = '%s' + _snmp_f7_ = '%s', _snmp_f8_ = '%s', _snmp_f9_ = '%s', + _snmp_f10_ = '%s', trap_type = %d, single_value = '%s' WHERE id_as = %d", $priority, $alert_type, $al_field1, $al_field2, $al_field3, $al_field4, $al_field5, $al_field6, $al_field7, $al_field8, @@ -132,7 +141,8 @@ else if (isset ($_GET["submit"])) { $description, $source_ip, $custom_value, $oid, $time_threshold, $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, $trap_type, $single_value, $id_as); + $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); $result = db_process_sql ($sql); @@ -181,6 +191,10 @@ if ((isset ($_GET["update_alert"])) && ($_GET["update_alert"] != -1)) { $custom_oid_data_4 = $alert["_snmp_f4_"]; $custom_oid_data_5 = $alert["_snmp_f5_"]; $custom_oid_data_6 = $alert["_snmp_f6_"]; + $custom_oid_data_7 = $alert["_snmp_f7_"]; + $custom_oid_data_8 = $alert["_snmp_f8_"]; + $custom_oid_data_9 = $alert["_snmp_f9_"]; + $custom_oid_data_10 = $alert["_snmp_f10_"]; $trap_type = $alert["trap_type"]; $single_value = $alert["single_value"]; } @@ -212,6 +226,10 @@ elseif (isset ($_GET["update_alert"])) { $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 = -1; $single_value = ''; } @@ -327,7 +345,31 @@ if (isset ($_GET["update_alert"])) { echo ''; html_print_input_text ("custom_oid_data_6", $custom_oid_data_6, '', 60); echo ''; - + + // Custom OID/Data #7 + echo ''.__('Custom OID/Data #7'); + echo ''; + html_print_input_text ("custom_oid_data_7", $custom_oid_data_7, '', 60); + echo ''; + + // Custom OID/Data #8 + echo ''.__('Custom OID/Data #8'); + echo ''; + html_print_input_text ("custom_oid_data_8", $custom_oid_data_8, '', 60); + echo ''; + + // Custom OID/Data #9 + echo ''.__('Custom OID/Data #9'); + echo ''; + html_print_input_text ("custom_oid_data_9", $custom_oid_data_9, '', 60); + echo ''; + + // Custom OID/Data #10 + echo ''.__('Custom OID/Data #10'); + echo ''; + html_print_input_text ("custom_oid_data_10", $custom_oid_data_10, '', 60); + echo ''; + //Button //echo ''; diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index 7000ff546b..c67c1dc772 100644 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -150,7 +150,7 @@ switch ($config["dbtype"]) { } $traps = db_get_all_rows_sql ($sql); // All traps -$all_traps = db_get_all_rows_sql ("SELECT * FROM ttrap"); +$all_traps = db_get_all_rows_sql ("SELECT DISTINCT source FROM ttrap"); if (($config['dbtype'] == 'oracle') && ($traps !== false)) { for ($i=0; $i < count($traps); $i++) { @@ -364,10 +364,11 @@ $table->data[2][3] = html_print_select ($severities, 'filter_severity', $filter_ // Status $table->data[3][0] = ''.__('Status').''; -$status[-1] = __('All'); -$status[0] = __('Not validated'); -$status[1] = __('Validated'); -$table->data[3][1] = html_print_select ($status, 'filter_status', $filter_status, 'this.form.submit();', '', '', true); + +$status_array[-1] = __('All'); +$status_array[0] = __('Not validated'); +$status_array[1] = __('Validated'); +$table->data[3][1] = html_print_select ($status_array, 'filter_status', $filter_status, 'this.form.submit();', '', '', true); // Free search (search by all alphanumeric fields) $table->data[3][3] = ''.__('Free search').'' . ui_print_help_tip(__('Search by any alphanumeric field in the trap'), true); @@ -572,7 +573,15 @@ if ($traps !== false) { $string = ' - + diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 2d93ba6fbc..4ed750d2ef 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -297,6 +297,10 @@ CREATE TABLE talert_snmp ( _snmp_f4_ CLOB default '', _snmp_f5_ CLOB default '', _snmp_f6_ CLOB default '', + _snmp_f7_ CLOB default '', + _snmp_f8_ CLOB default '', + _snmp_f9_ CLOB default '', + _snmp_f10_ CLOB default '', trap_type NUMBER(10, 0) DEFAULT -1 NOT NULL, single_value VARCHAR2(255) DEFAULT '' ); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index 684a494bf5..7a6c85d0cf 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -281,6 +281,10 @@ CREATE TABLE "talert_snmp" ( "_snmp_f4_" text DEFAULT '', "_snmp_f5_" text DEFAULT '', "_snmp_f6_" text DEFAULT '', + "_snmp_f7_" text DEFAULT '', + "_snmp_f8_" text DEFAULT '', + "_snmp_f9_" text DEFAULT '', + "_snmp_f10_" text DEFAULT '', "trap_type" INTEGER NOT NULL DEFAULT '-1', "single_value" varchar(255) DEFAULT '' ); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b8f0aef196..f457ae0d93 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -287,6 +287,10 @@ CREATE TABLE IF NOT EXISTS `talert_snmp` ( `_snmp_f4_` text, `_snmp_f5_` text, `_snmp_f6_` text, + `_snmp_f7_` text, + `_snmp_f8_` text, + `_snmp_f9_` text, + `_snmp_f10_` text, `trap_type` int(11) NOT NULL default '-1', `single_value` varchar(255) default '', PRIMARY KEY (`id_as`) @@ -862,7 +866,8 @@ CREATE TABLE IF NOT EXISTS `ttrap` ( `severity` tinyint(4) unsigned NOT NULL default '2', PRIMARY KEY (`id_trap`), INDEX timestamp (`timestamp`), - INDEX status (`status`) + INDEX status (`status`), + INDEX source (`source`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ----------------------------------------------------------------------
' . __('Custom data:') . '' . $trap['oid_custom'] . ''; + + // Print binding vars separately + $binding_vars = explode ("\t", $trap['oid_custom']); + foreach ($binding_vars as $var) { + $string .= $var . "
"; + } + + $string .= '
' . '' . __('OID:') . '