From e0bd98b9e2f605c125db7ae054bfff6bce8769a2 Mon Sep 17 00:00:00 2001 From: ramonn Date: Thu, 12 Aug 2010 12:23:25 +0000 Subject: [PATCH] 2010-08-12 Ramon Novoa * include/functions_alerts.php, godmode/alerts/configure_alert_template.php: Added support for unknown status alerts. * pandoradb.sql, godmode/menu.php, extras/pandoradb_migrate_v3.1_to_v3.2.sql: Added support for SNMP filters. * godmode/snmpconsole/snmp_filters.php: Added to repository. SNMP filter editor. * operation/snmpconsole/snmp_view.php: Fixed header placement. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3132 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 15 ++ .../extras/pandoradb_migrate_v3.1_to_v3.2.sql | 18 +++ .../alerts/configure_alert_template.php | 8 + pandora_console/godmode/menu.php | 1 + .../godmode/snmpconsole/snmp_filters.php | 146 ++++++++++++++++++ pandora_console/include/functions_alerts.php | 3 +- .../operation/snmpconsole/snmp_view.php | 21 ++- pandora_console/pandoradb.sql | 12 +- 8 files changed, 211 insertions(+), 13 deletions(-) create mode 100644 pandora_console/godmode/snmpconsole/snmp_filters.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 3e65b13ac4..a5c9cd3e0f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,18 @@ +2010-08-12 Ramon Novoa + + * include/functions_alerts.php, + godmode/alerts/configure_alert_template.php: Added support for + unknown status alerts. + + * pandoradb.sql, godmode/menu.php, + extras/pandoradb_migrate_v3.1_to_v3.2.sql: Added support for SNMP + filters. + + * godmode/snmpconsole/snmp_filters.php: Added to repository. SNMP + filter editor. + + * operation/snmpconsole/snmp_view.php: Fixed header placement. + 2010-08-12 Sergio Martin * include/functions_html.php: Added the function html2rgb for diff --git a/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql b/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql index 02660e3847..fbd974312e 100644 --- a/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql +++ b/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql @@ -73,3 +73,21 @@ ALTER TABLE `tagente_modulo` ADD COLUMN `id_policy_module` INTEGER UNSIGNED NOT -- Table `talert_template_modules` -- ----------------------------------------------------- ALTER TABLE `talert_template_modules` ADD COLUMN `id_policy_alerts` int(10) unsigned NOT NULL default '0'; + + +-- ----------------------------------------------------- +-- Table `tsnmp_filter` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tsnmp_filter` ( + `id_snmp_filter` int(10) unsigned NOT NULL auto_increment, + `description` varchar(255) default '', + `filter` varchar(255) default '', + PRIMARY KEY (`id_snmp_filter`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ----------------------------------------------------- +-- Table `talert_templates` +-- ----------------------------------------------------- +ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critica +l', 'onchange', 'unknown'); + diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index fc988609dd..711fe5c197 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -530,6 +530,7 @@ var warning = ""; var onchange = ""; var onchange_not = ""; +var unknown = ""; function check_regex () { if ($("#type").attr ('value') != 'regex') { @@ -656,6 +657,13 @@ $(document).ready (function () { else $("span#example").empty ().append (onchange_not); break; + case "unknown": + $("#template-value, #template-max, span#matches_value, #template-min").hide (); + $("#template-example").show (); + + /* Show example */ + $("span#example").empty ().append (unknown); + break; default: $("#template-value, #template-max, #template-min, #template-example, span#matches_value").hide (); break; diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 195875377a..a5b62f24c5 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -102,6 +102,7 @@ if (give_acl($config['id_user'], 0, "LW")) { $sub = array (); //$sub["godmode/snmpconsole/snmp_alert"]["text"] = __('Component groups'); + $sub['godmode/snmpconsole/snmp_filters']['text'] = __('SNMP filters'); enterprise_hook ('snmpconsole_submenu'); diff --git a/pandora_console/godmode/snmpconsole/snmp_filters.php b/pandora_console/godmode/snmpconsole/snmp_filters.php new file mode 100644 index 0000000000..34d2cf63c9 --- /dev/null +++ b/pandora_console/godmode/snmpconsole/snmp_filters.php @@ -0,0 +1,146 @@ + -2) { + if ($edit_filter > -1) { + print_page_header (__('SNMP Console')." » ".__('Update filter'), "images/computer_error.png", false, "", true); + } else { + print_page_header (__('SNMP Console')." » ".__('Create filter'), "images/computer_error.png", false, "", true); + } +// Overview header +} else { + print_page_header (__('SNMP Console')." » ".__('Filter overview'), "images/computer_error.png", false, "", true); +} + +// Create/update filter +if ($update_filter > -2) { + if ($update_filter > -1) { + $sql = sprintf ("UPDATE tsnmp_filter SET description = '%s', filter = '%s' WHERE id_snmp_filter = %d", $description, $filter, $update_filter); + if (process_sql ($sql) === false) { + print_error_message (__('There was a problem updating the filter')); + } else { + print_success_message (__('Successfully updated')); + } + } else { + $sql = sprintf ("INSERT INTO tsnmp_filter (description, filter) VALUES ('%s', '%s')", $description, $filter); + if (process_sql ($sql) === false) { + print_error_message (__('There was a problem creating the filter')); + } else { + print_success_message (__('Successfully created')); + } + } +// Delete +} else if ($delete_filter > -1) { + $sql = sprintf ("DELETE FROM tsnmp_filter WHERE id_snmp_filter = %d", $delete_filter); + if (process_sql ($sql) === false) { + print_error_message (__('There was a problem deleting the filter')); + } else { + print_success_message (__('Successfully deleted')); + } +} + +// Read filter data from the database +if ($edit_filter > -1) { + $filter = get_db_row ('tsnmp_filter', 'id_snmp_filter', $edit_filter); + if ($filter !== false) { + $description = $filter['description']; + $filter = $filter['filter']; + } +} + +// Create/update form +if ($edit_filter > -2) { + $table->data = array (); + $table->width = '90%'; + $table->data[0][0] = __('Description'); + $table->data[0][1] = print_input_text ('description', $description, '', 60, 100, true); + $table->data[1][0] = __('Filter'); + $table->data[1][1] = print_input_text ('filter', $filter, '', 60, 100, true); + + echo '
'; + print_input_hidden ('update_filter', $edit_filter); + print_table ($table); + echo '
'; + if ($edit_filter > -1) { + print_submit_button (__('Update'), 'submit_button', false, 'class="sub upd"'); + } else { + print_submit_button (__('Create'), 'submit_button', false, 'class="sub upd"'); + } + echo '
'; + echo '
'; +// Overview +} else { + $result = get_db_all_rows_in_table ("tsnmp_filter"); + if ($result === false) { + $result = array (); + echo "
".__('There are no SNMP filters')."
"; + } + + $table->data = array (); + $table->head = array (); + $table->size = array (); + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->width = 750; + $table->class= "databox"; + $table->align = array (); + + $table->head[0] = __('Description'); + $table->head[1] = __('Filter'); + $table->head[2] = __('Action'); + $table->size[2] = 50; + $table->align[2] = 'right'; + + foreach ($result as $row) { + $data = array (); + $data[0] = $row['description']; + $data[1] = $row['filter']; + $data[2] = ' + '.__('Delete').'  + + '.__('Update').''; + array_push ($table->data, $data); + } + + if (!empty ($table->data)) { + print_table ($table); + } + + unset ($table); + + echo '
'; + echo '
'; + print_submit_button (__('Create'), 'submit_button', false, 'class="sub next"'); + echo '
'; +} + +?> diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index c001a3a596..73f944163a 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -215,7 +215,8 @@ function get_alert_templates_types () { $types['not_equal'] = __('Not equal to'); $types['warning'] = __('Warning status'); $types['critical'] = __('Critical status'); - $types['onchange'] = __('On Change'); + $types['unknown'] = __('Unknown status'); + $types['onchange'] = __('On Change'); return $types; } diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index 1eb4e56473..8aade76269 100644 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -39,6 +39,16 @@ $pagination = (int) get_parameter ("pagination", $config["block_size"]); $offset = (int) get_parameter ('offset',0); $url = "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&filter_agent=".$filter_agent."&filter_oid=".$filter_oid."&filter_severity=".$filter_severity."&filter_fired=".$filter_fired."&search_string=".$search_string."&pagination=".$pagination."&offset=".$offset; +if ($config["pure"]) { + $link = ''; +} else { + // Fullscreen + $link = ''; +} + +// Header +print_page_header (__("SNMP Console"), "images/computer_error.png", false, "", false, $link); + // OPERATIONS // Delete SNMP Trap entry Event (only incident management access). @@ -99,17 +109,6 @@ if (isset ($_POST["updatebt"])) { } } -if ($config["pure"]) { - $link = ''; -} else { - // Fullscreen - $link = ''; -} - -// Header -print_page_header (__("SNMP Console"), "images/computer_error.png", false, "", false, $link); - - $sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC LIMIT %d,%d",$offset,$config['block_size']); $traps = get_db_all_rows_sql ($sql); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index adc304da5f..15d9ce694a 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -248,7 +248,7 @@ CREATE TABLE IF NOT EXISTS `talert_templates` ( `field1` varchar(255) default '', `field2` varchar(255) default '', `field3` mediumtext NOT NULL, - `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange'), + `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange', 'unknown'), `value` varchar(255) default '', `matches_value` tinyint(1) default 0, `max_value` double(18,2) default NULL, @@ -1126,4 +1126,14 @@ CREATE TABLE IF NOT EXISTS `tnetwork_map` ( PRIMARY KEY (`id_networkmap`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ----------------------------------------------------- +-- Table `tsnmp_filter` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `tsnmp_filter` ( + `id_snmp_filter` int(10) unsigned NOT NULL auto_increment, + `description` varchar(255) default '', + `filter` varchar(255) default '', + PRIMARY KEY (`id_snmp_filter`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;