2011-07-08 Koichiro Kikuchi <koichiro@rworks.jp>
* lib/PandoraFMS/Core.pm: Fixed alert macro substitution. Now alert_macro_substitute() does not substitute already substituted part of string. Also fixed alert macro substitution for user defined alerts to avoid alert macros other than _field[1-3]_ substituted twice. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4535 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
47b551da9a
commit
f7eede5b9e
|
@ -1,3 +1,11 @@
|
||||||
|
2011-07-08 Koichiro Kikuchi <koichiro@rworks.jp>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Core.pm: Fixed alert macro substitution. Now
|
||||||
|
alert_macro_substitute() does not substitute already substituted
|
||||||
|
part of string. Also fixed alert macro substitution for user
|
||||||
|
defined alerts to avoid alert macros other than _field[1-3]_
|
||||||
|
substituted twice.
|
||||||
|
|
||||||
2011-07-08 Ramon Novoa <rnovoa@artica.es>
|
2011-07-08 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* lib/PandoraFMS/Core.pm: Fixed alert-only planned downtimes.
|
* lib/PandoraFMS/Core.pm: Fixed alert-only planned downtimes.
|
||||||
|
|
|
@ -725,8 +725,10 @@ sub pandora_execute_action ($$$$$$$$$;$) {
|
||||||
|
|
||||||
# User defined alerts
|
# User defined alerts
|
||||||
if ($action->{'internal'} == 0) {
|
if ($action->{'internal'} == 0) {
|
||||||
|
$macros{_field1_} = subst_alert_macros ($field1, \%macros);
|
||||||
|
$macros{_field2_} = subst_alert_macros ($field2, \%macros);
|
||||||
|
$macros{_field3_} = subst_alert_macros ($field3, \%macros);
|
||||||
my $command = subst_alert_macros (decode_entities ($action->{'command'}), \%macros);
|
my $command = subst_alert_macros (decode_entities ($action->{'command'}), \%macros);
|
||||||
$command = subst_alert_macros ($command, \%macros);
|
|
||||||
logger($pa_config, "Executing command '$command' for action '" . $action->{'name'} . "' alert '". $alert->{'name'} . "' agent '" . (defined ($agent) ? $agent->{'nombre'} : 'N/A') . "'.", 8);
|
logger($pa_config, "Executing command '$command' for action '" . $action->{'name'} . "' alert '". $alert->{'name'} . "' agent '" . (defined ($agent) ? $agent->{'nombre'} : 'N/A') . "'.", 8);
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
|
@ -1693,16 +1695,10 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
||||||
sub subst_alert_macros ($$) {
|
sub subst_alert_macros ($$) {
|
||||||
my ($string, $macros) = @_;
|
my ($string, $macros) = @_;
|
||||||
|
|
||||||
while ((my $macro, my $value) = each (%{$macros})) {
|
my $macro_regexp = join('|', grep { defined $macros->{$_} } keys %{$macros});
|
||||||
|
|
||||||
# Undefined macro value
|
# Macro data may contain HTML entities
|
||||||
next unless defined ($value);
|
$string =~ s/($macro_regexp)/decode_entities($macros->{$1})/ige;
|
||||||
|
|
||||||
# Macro data may contain HTML entities
|
|
||||||
my $decoded_value = decode_entities ($value);
|
|
||||||
|
|
||||||
$string =~ s/($macro)/$decoded_value/ig;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue