diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 4b1b207f29..240aa779bc 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-02-21 Sergio Martin + + * extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql + extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql + extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql + godmode/alerts/configure_alert_action.php + godmode/alerts/alert_commands.php: Update the commands data + to new alerts macro in migration. Hide the not used fields + on actions. bug #3605461 + 2013-02-21 Sergio Martin * include/functions_graph.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 da62cb7306..f7cdedbbce 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 @@ -1079,3 +1079,15 @@ ALTER TABLE tevento ADD INDEX `idx_utimestamp` USING BTREE (`utimestamp`); ALTER TABLE tserver DROP INDEX keepalive; ALTER TABLE tserver DROP INDEX status; +------------------------------------------------------------------------ +-- Adapt the talert commands to new macro system +------------------------------------------------------------------------ + +UPDATE talert_commands SET fields_descriptions = '["Destination address","Subject","Text","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 1; +UPDATE talert_commands SET fields_descriptions = '["Description","","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 2; +UPDATE talert_commands SET fields_descriptions = '["Event text","Event type","Source","Agent name or _agent_","Event criticity","ID extra","Tags separated by commas","Comments","Not used","Not used"]', fields_values = '["","alert_ceased,Alert ceased;alert_fired,Alert fired;alert_manual_validation,Alert manual validation;alert_recovered,Alert recovered;configuration_change,Configuration change ;error,Error;critical,Monitor Critical;normal,Monitor Normal;going_unknown,Monitor","","","4,Critical;1,Informational;0,Maintenance;6,Major;5,Minor;2,Normal;3,Warning","","","","",""]' WHERE id = 3; +UPDATE talert_commands SET fields_descriptions = '["Log Info 1","Log Info 2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 4; +UPDATE talert_commands SET fields_descriptions = '["Community","Destination address","OID","Source address","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 5; +UPDATE talert_commands SET fields_descriptions = '["Log Info 1","Log Info 2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 6; +UPDATE talert_commands SET fields_descriptions = '["Destination number","Message","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 9; +UPDATE talert_commands SET fields_descriptions = '["Agent name","Module name","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 10; 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 91a834b22a..73d8c37f96 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 @@ -1082,3 +1082,16 @@ INSERT INTO tnetwork_component_group (id_sg, name, parent) SELECT * FROM (SELECT INSERT INTO tnetwork_component_group (id_sg, name, parent) SELECT * FROM (SELECT 46,'AIX',5 FROM dual) AS tmp WHERE NOT EXISTS (SELECT id_sg FROM tnetwork_component_group WHERE id_sg = 46); INSERT INTO tnetwork_component_group (id_sg, name, parent) SELECT * FROM (SELECT 47,'BSD',5 FROM dual) AS tmp WHERE NOT EXISTS (SELECT id_sg FROM tnetwork_component_group WHERE id_sg = 47); INSERT INTO tnetwork_component_group (id_sg, name, parent) SELECT * FROM (SELECT 48,'MacOS',0 FROM dual) AS tmp WHERE NOT EXISTS (SELECT id_sg FROM tnetwork_component_group WHERE id_sg = 48); + +------------------------------------------------------------------------ +-- Adapt the talert commands to new macro system +------------------------------------------------------------------------ + +UPDATE talert_commands SET fields_descriptions = '["Destination address","Subject","Text","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 1; +UPDATE talert_commands SET fields_descriptions = '["Description","","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 2; +UPDATE talert_commands SET fields_descriptions = '["Event text","Event type","Source","Agent name or _agent_","Event criticity","ID extra","Tags separated by commas","Comments","Not used","Not used"]', fields_values = '["","alert_ceased,Alert ceased;alert_fired,Alert fired;alert_manual_validation,Alert manual validation;alert_recovered,Alert recovered;configuration_change,Configuration change ;error,Error;critical,Monitor Critical;normal,Monitor Normal;going_unknown,Monitor","","","4,Critical;1,Informational;0,Maintenance;6,Major;5,Minor;2,Normal;3,Warning","","","","",""]' WHERE id = 3; +UPDATE talert_commands SET fields_descriptions = '["Log Info 1","Log Info 2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 4; +UPDATE talert_commands SET fields_descriptions = '["Community","Destination address","OID","Source address","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 5; +UPDATE talert_commands SET fields_descriptions = '["Log Info 1","Log Info 2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 6; +UPDATE talert_commands SET fields_descriptions = '["Destination number","Message","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 9; +UPDATE talert_commands SET fields_descriptions = '["Agent name","Module name","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 10; 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 5234aac014..1ff5ff2ec6 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 @@ -1073,3 +1073,16 @@ INSERT INTO "tnetwork_component_group" ("id_sg", "name", "parent") SELECT * FROM INSERT INTO "tnetwork_component_group" ("id_sg", "name", "parent") SELECT * FROM (SELECT 46,'AIX',5 FROM dual) AS tmp WHERE NOT EXISTS (SELECT "id_sg" FROM "tnetwork_component_group" WHERE "id_sg" = 46); INSERT INTO "tnetwork_component_group" ("id_sg", "name", "parent") SELECT * FROM (SELECT 47,'BSD',5 FROM dual) AS tmp WHERE NOT EXISTS (SELECT "id_sg" FROM "tnetwork_component_group" WHERE "id_sg" = 47); INSERT INTO "tnetwork_component_group" ("id_sg", "name", "parent") SELECT * FROM (SELECT 48,'MacOS',0 FROM dual) AS tmp WHERE NOT EXISTS (SELECT "id_sg" FROM "tnetwork_component_group" WHERE "id_sg" = 48); + +------------------------------------------------------------------------ +-- Adapt the talert commands to new macro system +------------------------------------------------------------------------ + +UPDATE "talert_commands" SET "fields_descriptions" = '["Destination address","Subject","Text","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 1; +UPDATE "talert_commands" SET "fields_descriptions" = '["Description","","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 2; +UPDATE "talert_commands" SET "fields_descriptions" = '["Event text","Event type","Source","Agent name or _agent_","Event criticity","ID extra","Tags separated by commas","Comments","Not used","Not used"]', fields_values = '["","alert_ceased,Alert ceased;alert_fired,Alert fired;alert_manual_validation,Alert manual validation;alert_recovered,Alert recovered;configuration_change,Configuration change ;error,Error;critical,Monitor Critical;normal,Monitor Normal;going_unknown,Monitor","","","4,Critical;1,Informational;0,Maintenance;6,Major;5,Minor;2,Normal;3,Warning","","","","",""]' WHERE id = 3; +UPDATE "talert_commands" SET "fields_descriptions" = '["Log Info 1","Log Info 2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 4; +UPDATE "talert_commands" SET "fields_descriptions" = '["Community","Destination address","OID","Source address","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 5; +UPDATE "talert_commands" SET "fields_descriptions" = '["Log Info 1","Log Info 2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 6; +UPDATE "talert_commands" SET "fields_descriptions" = '["Destination number","Message","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 9; +UPDATE "talert_commands" SET "fields_descriptions" = '["Agent name","Module name","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 10; diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 838115bd58..c31bc20393 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -61,7 +61,13 @@ if (is_ajax ()) { $fdesc = $fields_descriptions[$i-1].'
'.sprintf(__('Field %s'), $i).''; } else { - $fdesc = sprintf(__('Field %s'), $i); + // If the macro hasn't description and doesnt appear in command, set with empty description to dont show it + if(substr_count($command['command'], "_field$i_") > 0) { + $fdesc = sprintf(__('Field %s'), $i); + } + else { + $fdesc = ''; + } } if(!empty($fields_values[$i-1])) { @@ -84,14 +90,20 @@ if (is_ajax ()) { $ffield = html_print_textarea ('field'.$i.'_value', 1, 1, '', 'style="min-height:40px" class="fields"', true); } - $fields_rows[$i] = ' - - '.$fdesc.' - - - '.$ffield.' - - '; + // The empty descriptions will be ignored + if($fdesc == '') { + $fields_rows[$i] = ''; + } + else { + $fields_rows[$i] = ' + + '.$fdesc.' + + + '.$ffield.' + + '; + } } $command['fields_rows'] = $fields_rows; diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 472f064112..e4d6b1cd3b 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -206,8 +206,15 @@ $(document).ready (function () { old_value = $("[name=field"+i+"_value]").val(); } - $('#table1-field'+i).replaceWith(data["fields_rows"][i]); - $("[name=field"+i+"_value]").val(old_value); + // If the row is empty, hide de row + if(data["fields_rows"][i] == '') { + $('#table1-field'+i).hide(); + } + else { + $('#table1-field'+i).replaceWith(data["fields_rows"][i]); + $("[name=field"+i+"_value]").val(old_value); + $('#table1-field').show(); + } } render_command_preview(original_command);