From ef043a169aa5a368aa6442ea30c6ee4a9af67d53 Mon Sep 17 00:00:00 2001 From: Luis Date: Fri, 25 Sep 2020 10:47:36 +0200 Subject: [PATCH] Increased number of max macro data fields from 15 to 20 --- pandora_console/extras/mr/42.sql | 15 ++++++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 10 ++++ pandora_console/godmode/setup/performance.php | 4 +- pandora_console/pandoradb.sql | 10 ++++ pandora_server/lib/PandoraFMS/Core.pm | 47 ++++++++++++++++++- 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 pandora_console/extras/mr/42.sql diff --git a/pandora_console/extras/mr/42.sql b/pandora_console/extras/mr/42.sql new file mode 100644 index 0000000000..3e17285ef7 --- /dev/null +++ b/pandora_console/extras/mr/42.sql @@ -0,0 +1,15 @@ +START TRANSACTION; + +ALTER TABLE talert_actions ADD COLUMN `field16` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field17` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field18` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field19` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field20` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field16_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field17_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field18_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field19_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field20_recovery` TEXT NOT NULL DEFAULT ""; + + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index a8e1deae9a..1c646e8bea 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1308,11 +1308,21 @@ ALTER TABLE talert_actions ADD COLUMN `field12` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field13` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field14` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field15` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field16` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field17` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field18` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field19` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field20` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field11_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field12_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field13_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field14_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field16_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field17_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field18_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field19_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE talert_actions ADD COLUMN `field20_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE `talert_actions` ADD COLUMN `previous_name` text; ALTER TABLE `talert_actions` MODIFY COLUMN `field11` text NOT NULL, diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 422321ee6e..096defb664 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -685,8 +685,8 @@ function change_macro_fields() { if (value <= 0) { $("#text-max_macro_fields").val(1); } - else if (value > 15) { - $("#text-max_macro_fields").val(15); + else if (value > 20) { + $("#text-max_macro_fields").val(20); } } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 7121fb134c..11a8310aa5 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -407,6 +407,11 @@ CREATE TABLE IF NOT EXISTS `talert_actions` ( `field13` text NOT NULL, `field14` text NOT NULL, `field15` text NOT NULL, + `field16` text NOT NULL, + `field17` text NOT NULL, + `field18` text NOT NULL, + `field19` text NOT NULL, + `field20` text NOT NULL, `id_group` mediumint(8) unsigned NULL default 0, `action_threshold` int(10) NOT NULL default '0', `field1_recovery` text NOT NULL, @@ -424,6 +429,11 @@ CREATE TABLE IF NOT EXISTS `talert_actions` ( `field13_recovery` text NOT NULL, `field14_recovery` text NOT NULL, `field15_recovery` text NOT NULL, + `field16_recovery` text NOT NULL, + `field17_recovery` text NOT NULL, + `field18_recovery` text NOT NULL, + `field19_recovery` text NOT NULL, + `field20_recovery` text NOT NULL, `previous_name` text, PRIMARY KEY (`id`), FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 3eff8e2384..a67000b504 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -997,7 +997,7 @@ sub pandora_execute_action ($$$$$$$$$;$) { my $clean_name = safe_output($action->{'name'}); my ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10); - my ($field11, $field12, $field13, $field14, $field15); + my ($field11, $field12, $field13, $field14, $field15, $field16, $field17, $field18, $field19, $field20); if (!defined($alert->{'snmp_alert'})) { # Regular alerts @@ -1016,6 +1016,11 @@ sub pandora_execute_action ($$$$$$$$$;$) { $field13 = defined($action->{'field13'}) && $action->{'field13'} ne "" ? $action->{'field13'} : $alert->{'field13'}; $field14 = defined($action->{'field14'}) && $action->{'field14'} ne "" ? $action->{'field14'} : $alert->{'field14'}; $field15 = defined($action->{'field15'}) && $action->{'field15'} ne "" ? $action->{'field15'} : $alert->{'field15'}; + $field16 = defined($action->{'field16'}) && $action->{'field16'} ne "" ? $action->{'field16'} : $alert->{'field16'}; + $field17 = defined($action->{'field17'}) && $action->{'field17'} ne "" ? $action->{'field17'} : $alert->{'field17'}; + $field18 = defined($action->{'field18'}) && $action->{'field18'} ne "" ? $action->{'field18'} : $alert->{'field18'}; + $field19 = defined($action->{'field19'}) && $action->{'field19'} ne "" ? $action->{'field19'} : $alert->{'field19'}; + $field20 = defined($action->{'field20'}) && $action->{'field20'} ne "" ? $action->{'field20'} : $alert->{'field20'}; } else { $field1 = defined($action->{'field1'}) && $action->{'field1'} ne "" ? $action->{'field1'} : $alert->{'field1'}; @@ -1033,6 +1038,11 @@ sub pandora_execute_action ($$$$$$$$$;$) { $field13 = defined($action->{'field13'}) && $action->{'field13'} ne "" ? $action->{'field13'} : $alert->{'field13'}; $field14 = defined($action->{'field14'}) && $action->{'field14'} ne "" ? $action->{'field14'} : $alert->{'field14'}; $field15 = defined($action->{'field15'}) && $action->{'field15'} ne "" ? $action->{'field15'} : $alert->{'field15'}; + $field16 = defined($action->{'field16'}) && $action->{'field16'} ne "" ? $action->{'field16'} : $alert->{'field16'}; + $field17 = defined($action->{'field17'}) && $action->{'field17'} ne "" ? $action->{'field17'} : $alert->{'field17'}; + $field18 = defined($action->{'field18'}) && $action->{'field18'} ne "" ? $action->{'field18'} : $alert->{'field18'}; + $field19 = defined($action->{'field19'}) && $action->{'field19'} ne "" ? $action->{'field19'} : $alert->{'field19'}; + $field20 = defined($action->{'field20'}) && $action->{'field20'} ne "" ? $action->{'field20'} : $alert->{'field20'}; } # Recovery fields, thanks to Kato Atsushi @@ -1096,6 +1106,26 @@ sub pandora_execute_action ($$$$$$$$$;$) { $field15 = defined($field15) && $field15 ne "" ? "[RECOVER]" . $field15 : ""; $field15 = defined($alert->{'field15_recovery'}) && $alert->{'field15_recovery'} ne "" ? $alert->{'field15_recovery'} : $field15; $field15 = defined($action->{'field15_recovery'}) && $action->{'field15_recovery'} ne "" ? $action->{'field15_recovery'} : $field15; + + $field16 = defined($field16) && $field16 ne "" ? "[RECOVER]" . $field16 : ""; + $field16 = defined($alert->{'field16_recovery'}) && $alert->{'field16_recovery'} ne "" ? $alert->{'field16_recovery'} : $field16; + $field16 = defined($action->{'field16_recovery'}) && $action->{'field16_recovery'} ne "" ? $action->{'field16_recovery'} : $field16; + + $field17 = defined($field17) && $field17 ne "" ? "[RECOVER]" . $field17 : ""; + $field17 = defined($alert->{'field17_recovery'}) && $alert->{'field17_recovery'} ne "" ? $alert->{'field17_recovery'} : $field17; + $field17 = defined($action->{'field17_recovery'}) && $action->{'field17_recovery'} ne "" ? $action->{'field17_recovery'} : $field17; + + $field18 = defined($field18) && $field18 ne "" ? "[RECOVER]" . $field18 : ""; + $field18 = defined($alert->{'field18_recovery'}) && $alert->{'field18_recovery'} ne "" ? $alert->{'field18_recovery'} : $field18; + $field18 = defined($action->{'field18_recovery'}) && $action->{'field18_recovery'} ne "" ? $action->{'field18_recovery'} : $field18; + + $field19 = defined($field19) && $field19 ne "" ? "[RECOVER]" . $field19 : ""; + $field19 = defined($alert->{'field19_recovery'}) && $alert->{'field19_recovery'} ne "" ? $alert->{'field19_recovery'} : $field19; + $field19 = defined($action->{'field19_recovery'}) && $action->{'field19_recovery'} ne "" ? $action->{'field19_recovery'} : $field19; + + $field20 = defined($field20) && $field20 ne "" ? "[RECOVER]" . $field20 : ""; + $field20 = defined($alert->{'field20_recovery'}) && $alert->{'field20_recovery'} ne "" ? $alert->{'field20_recovery'} : $field20; + $field20 = defined($action->{'field20_recovery'}) && $action->{'field20_recovery'} ne "" ? $action->{'field20_recovery'} : $field20; } $field1 = defined($field1) && $field1 ne "" ? decode_entities($field1) : ""; @@ -1113,6 +1143,11 @@ sub pandora_execute_action ($$$$$$$$$;$) { $field13 = defined($field13) && $field13 ne "" ? decode_entities($field13) : ""; $field14 = defined($field14) && $field14 ne "" ? decode_entities($field14) : ""; $field15 = defined($field15) && $field15 ne "" ? decode_entities($field15) : ""; + $field16 = defined($field16) && $field16 ne "" ? decode_entities($field16) : ""; + $field17 = defined($field17) && $field17 ne "" ? decode_entities($field17) : ""; + $field18 = defined($field18) && $field18 ne "" ? decode_entities($field18) : ""; + $field19 = defined($field19) && $field19 ne "" ? decode_entities($field19) : ""; + $field20 = defined($field20) && $field20 ne "" ? decode_entities($field20) : ""; # Get group info my $group = undef; @@ -1147,6 +1182,11 @@ sub pandora_execute_action ($$$$$$$$$;$) { _field13_ => $field13, _field14_ => $field14, _field15_ => $field15, + _field11_ => $field16, + _field12_ => $field17, + _field13_ => $field18, + _field14_ => $field19, + _field15_ => $field20, _agentname_ => (defined ($agent)) ? $agent->{'nombre'} : '', _agentalias_ => (defined ($agent)) ? $agent->{'alias'} : '', _agent_ => (defined ($agent)) ? ($agent->{'alias'} ? $agent->{'alias'} : $agent->{'nombre'}) : '', @@ -1229,6 +1269,11 @@ sub pandora_execute_action ($$$$$$$$$;$) { $macros{_field13_} = subst_alert_macros ($field13, \%macros, $pa_config, $dbh, $agent, $module, $alert); $macros{_field14_} = subst_alert_macros ($field14, \%macros, $pa_config, $dbh, $agent, $module, $alert); $macros{_field15_} = subst_alert_macros ($field15, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $macros{_field16_} = subst_alert_macros ($field16, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $macros{_field17_} = subst_alert_macros ($field17, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $macros{_field18_} = subst_alert_macros ($field18, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $macros{_field19_} = subst_alert_macros ($field19, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $macros{_field20_} = subst_alert_macros ($field20, \%macros, $pa_config, $dbh, $agent, $module, $alert); my @command_args = (); # divide command into words based on quotes and whitespaces