From f999cc1564205842b9db19d4a34343cffae16a83 Mon Sep 17 00:00:00 2001 From: ramonn Date: Wed, 4 Nov 2009 18:10:48 +0000 Subject: [PATCH] 2009-11-04 Ramon Novoa * godmode/snmpconsole/snmp_alert.php: An agent, OID and custom OID may be specified at the same time. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2083 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 + .../godmode/snmpconsole/snmp_alert.php | 120 +++++------------- 2 files changed, 37 insertions(+), 88 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 845e4a6869..1ba539c1a6 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2009-11-04 Ramon Novoa + + * godmode/snmpconsole/snmp_alert.php: An agent, OID and custom OID may + be specified at the same time. + 2009-11-04 Raul Mateos * operation/agentes/alerts_status.php: different colour for table header. diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 35c65af1dc..54dd4c269b 100644 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -43,7 +43,6 @@ if (isset ($_GET["submit"])) { $id_as = (int) get_parameter_get ("submit", -1); $source_ip = (string) get_parameter_post ("source_ip"); $alert_type = (int) get_parameter_post ("alert_type"); //Event, e-mail - $alert_trigger = (int) get_parameter_post ("alert_trigger"); //OID, Custom Value $description = (string) get_parameter_post ("description"); $oid = (string) get_parameter_post ("oid"); $custom_value = (string) get_parameter_post ("custom_value"); @@ -62,11 +61,11 @@ if (isset ($_GET["submit"])) { if ($id_as < 1) { $sql = sprintf ("INSERT INTO talert_snmp - (id_alert, al_field1, al_field2, al_field3, description, alert_type, + (id_alert, al_field1, al_field2, al_field3, description, agent, custom_oid, oid, time_threshold, max_alerts, min_alerts, priority) VALUES - (%d, '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d) ", - $alert_type, $al_field1, $al_field2, $al_field3, $description, $alert_trigger, $source_ip, $custom_value, $oid, $time_threshold, $max_alerts, $min_alerts, $priority); + (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d) ", + $alert_type, $al_field1, $al_field2, $al_field3, $description, $source_ip, $custom_value, $oid, $time_threshold, $max_alerts, $min_alerts, $priority); $result = process_sql ($sql); @@ -78,9 +77,9 @@ if (isset ($_GET["submit"])) { } else { $sql = sprintf ("UPDATE talert_snmp SET - priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', alert_type = %d, agent = '%s', custom_oid = '%s', + priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', agent = '%s', custom_oid = '%s', oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d WHERE id_as = %d", - $priority, $alert_type, $al_field1, $al_field2, $al_field3, $description, $alert_trigger, $source_ip, $custom_value, + $priority, $alert_type, $al_field1, $al_field2, $al_field3, $description, $source_ip, $custom_value, $oid, $time_threshold, $max_alerts, $min_alerts, $id_as); $result = process_sql ($sql); @@ -101,7 +100,6 @@ if ((isset ($_GET["update_alert"])) && ($_GET["update_alert"] != -1)) { $id_as = $alert["id_as"]; $source_ip = $alert["agent"]; $alert_type = $alert["id_alert"]; - $alert_trigger = $alert["alert_type"]; $description = $alert["description"]; $oid = $alert["oid"]; $custom_value = $alert["custom_oid"]; @@ -117,7 +115,6 @@ if ((isset ($_GET["update_alert"])) && ($_GET["update_alert"] != -1)) { $id_as = -1; $source_ip = ""; $alert_type = 1; //Event, e-mail - $alert_trigger = 0; //OID, Custom Value $description = ""; $oid = ""; $custom_value = ""; @@ -158,17 +155,6 @@ if (isset ($_GET["update_alert"])) { "alert_type", $alert_type, '', '', 0, false, false, false); echo ''; - // Alert trigger (OID, custom_value) - echo ''.__('Alert trigger').''; - - $fields = array (); - $fields[0] = "OID"; - $fields[1] = "Custom Value/OID"; - $fields[2] = "SNMP Agent"; - - print_select ($fields, "alert_trigger", $alert_trigger); - echo ''; - // Description echo ''.__('Description').''; print_input_text ("description", $description, '', 60); @@ -180,12 +166,12 @@ if (isset ($_GET["update_alert"])) { echo ''; // OID Custom - echo ''.__('Custom Value')."/".__("OID").''; + echo ''.__('Custom Value')."/".__("OID").''; print_input_text ("custom_value", $custom_value, '', 30); echo ''; // SNMP Agent - echo ''.__('SNMP Agent').' (IP)'; + echo ''.__('SNMP Agent').' (IP)'; print_input_text ("source_ip", $source_ip, '', 30); echo ''; @@ -270,64 +256,49 @@ if (isset ($_GET["update_alert"])) { $table->head[0] = __('Alert action'); - $table->head[1] = __('Alert trigger'); + $table->head[1] = __('SNMP Agent'); + $table->size[1] = 75; $table->align[1] = 'center'; - - $table->head[2] = __('SNMP Agent'); - $table->size[2] = 75; - $table->align[2] = 'center'; - $table->head[3] = __('OID'); + $table->head[2] = __('OID'); + $table->align[2] = 'center'; + + $table->head[3] = __('Custom Value/OID'); $table->align[3] = 'center'; - $table->head[4] = __('Custom Value/OID'); - $table->align[4] = 'center'; + $table->head[4] = __('Description'); - $table->head[5] = __('Description'); + $table->head[5] = __('Times fired'); + $table->align[5] = 'center'; - $table->head[6] = __('Times fired'); + $table->head[6] = __('Last fired'); $table->align[6] = 'center'; - - $table->head[7] = __('Last fired'); - $table->align[7] = 'center'; - $table->head[8] = __('Action'); - $table->size[8] = 50; - $table->align[8] = 'right'; + $table->head[7] = __('Action'); + $table->size[7] = 50; + $table->align[7] = 'right'; foreach ($result as $row) { $data = array (); $data[0] = get_alert_action_name ($row["id_alert"]); - $data[1] = __('N/A'); - $data[2] = __('N/A'); - $data[3] = __('N/A'); - $data[4] = __('N/A'); - - switch ($row["alert_type"]) { - case 0: - $data[1] = __('OID'); - $data[3] = $row["oid"]; - break; - case 1: - $data[1] = __('Custom Value/OID'); - $data[4] = $row["custom_oid"]; - break; - case 2: - $data[1] = __('SNMP Agent'); - $data[2] = $row["agent"]; - break; - } + + $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[5] = $row["description"]; - $data[6] = $row["times_fired"]; + $data[4] = $row["description"]; + $data[5] = $row["times_fired"]; if ($row["last_fired"] != "0000-00-00 00:00:00") { - $data[7] = $row["last_fired"]; + $data[6] = $row["last_fired"]; } else { - $data[7] = __('Never'); + $data[6] = __('Never'); } - $data[8] = ' + $data[7] = ' '.__('Delete').'  '.__('Update').''; @@ -367,34 +338,7 @@ function time_changed () { } } -function trigger_changed (trigger) { - if (trigger == 0) { - $('#tr-custom_value').fadeOut ('fast'); - $('#tr-source_ip').fadeOut ('fast'); - $('#tr-oid').fadeIn ('slow'); - return; - } - if (trigger == 1) { - $('#tr-oid').fadeOut ('fast'); - $('#tr-source_ip').fadeOut ('fast'); - $('#tr-custom_value').fadeIn ('slow'); - return; - } - if (trigger == 2) { - $('#tr-oid').fadeOut ('fast'); - $('#tr-custom_value').fadeOut ('fast'); - $('#tr-source_ip').fadeIn ('slow'); - return; - } -} - $(document).ready (function () { $('#time_threshold').change (time_changed); - $('#alert_trigger').change (function () { - trigger_changed (this.value) - }); - - trigger_changed (""); - });