2014-08-21 Hirofumi Kosaka <kosaka@rworks.jp>

* lib/PandoraFMS/Core.pm: Prevent some warnings would be
	written at pandora_server.error ("Use of uninitialized value
	in subroutine entry at ..." and "Use of uninitialized value in
	string ne at ..").

	MERGED FROM BRANCH 5.0 (rev10441).


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10442 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
hkosaka 2014-08-21 10:52:18 +00:00
parent 34ea647346
commit d172f5e26d
2 changed files with 68 additions and 59 deletions

View File

@ -1,3 +1,12 @@
2014-08-21 Hirofumi Kosaka <kosaka@rworks.jp>
* lib/PandoraFMS/Core.pm: Prevent some warnings would be
written at pandora_server.error ("Use of uninitialized value
in subroutine entry at ..." and "Use of uninitialized value in
string ne at ..").
MERGED FROM BRANCH 5.0 (rev10441).
2014-08-21 Junichi Satoh <junichi@rworks.jp> 2014-08-21 Junichi Satoh <junichi@rworks.jp>
* util/pandora_manage.pl: Added an option to add an event comment. * util/pandora_manage.pl: Added an option to add an event comment.

View File

@ -734,82 +734,82 @@ sub pandora_execute_action ($$$$$$$$$;$) {
if (!defined($alert->{'snmp_alert'})){ if (!defined($alert->{'snmp_alert'})){
# Regular alerts # Regular alerts
$field1 = $action->{'field1'} ne "" ? $action->{'field1'} : $alert->{'field1'}; $field1 = $action->{'field1'} ? $action->{'field1'} : $alert->{'field1'};
$field2 = $action->{'field2'} ne "" ? $action->{'field2'} : $alert->{'field2'}; $field2 = $action->{'field2'} ? $action->{'field2'} : $alert->{'field2'};
$field3 = $action->{'field3'} ne "" ? $action->{'field3'} : $alert->{'field3'}; $field3 = $action->{'field3'} ? $action->{'field3'} : $alert->{'field3'};
$field4 = $action->{'field4'} ne "" ? $action->{'field4'} : $alert->{'field4'}; $field4 = $action->{'field4'} ? $action->{'field4'} : $alert->{'field4'};
$field5 = $action->{'field5'} ne "" ? $action->{'field5'} : $alert->{'field5'}; $field5 = $action->{'field5'} ? $action->{'field5'} : $alert->{'field5'};
$field6 = $action->{'field6'} ne "" ? $action->{'field6'} : $alert->{'field6'}; $field6 = $action->{'field6'} ? $action->{'field6'} : $alert->{'field6'};
$field7 = $action->{'field7'} ne "" ? $action->{'field7'} : $alert->{'field7'}; $field7 = $action->{'field7'} ? $action->{'field7'} : $alert->{'field7'};
$field8 = $action->{'field8'} ne "" ? $action->{'field8'} : $alert->{'field8'}; $field8 = $action->{'field8'} ? $action->{'field8'} : $alert->{'field8'};
$field9 = $action->{'field9'} ne "" ? $action->{'field9'} : $alert->{'field9'}; $field9 = $action->{'field9'} ? $action->{'field9'} : $alert->{'field9'};
$field10 = $action->{'field10'} ne "" ? $action->{'field10'} : $alert->{'field10'}; $field10 = $action->{'field10'} ? $action->{'field10'} : $alert->{'field10'};
} else { } else {
$field1 = $alert->{'field1'} ne "" ? $alert->{'field1'} : $action->{'field1'}; $field1 = $alert->{'field1'} ? $alert->{'field1'} : $action->{'field1'};
$field2 = $alert->{'field2'} ne "" ? $alert->{'field2'} : $action->{'field2'}; $field2 = $alert->{'field2'} ? $alert->{'field2'} : $action->{'field2'};
$field3 = $alert->{'field3'} ne "" ? $alert->{'field3'} : $action->{'field3'}; $field3 = $alert->{'field3'} ? $alert->{'field3'} : $action->{'field3'};
$field4 = $action->{'field4'} ne "" ? $action->{'field4'} : $alert->{'field4'}; $field4 = $action->{'field4'} ? $action->{'field4'} : $alert->{'field4'};
$field5 = $action->{'field5'} ne "" ? $action->{'field5'} : $alert->{'field5'}; $field5 = $action->{'field5'} ? $action->{'field5'} : $alert->{'field5'};
$field6 = $action->{'field6'} ne "" ? $action->{'field6'} : $alert->{'field6'}; $field6 = $action->{'field6'} ? $action->{'field6'} : $alert->{'field6'};
$field7 = $action->{'field7'} ne "" ? $action->{'field7'} : $alert->{'field7'}; $field7 = $action->{'field7'} ? $action->{'field7'} : $alert->{'field7'};
$field8 = $action->{'field8'} ne "" ? $action->{'field8'} : $alert->{'field8'}; $field8 = $action->{'field8'} ? $action->{'field8'} : $alert->{'field8'};
$field9 = $action->{'field9'} ne "" ? $action->{'field9'} : $alert->{'field9'}; $field9 = $action->{'field9'} ? $action->{'field9'} : $alert->{'field9'};
$field10 = $action->{'field10'} ne "" ? $action->{'field10'} : $alert->{'field10'}; $field10 = $action->{'field10'} ? $action->{'field10'} : $alert->{'field10'};
} }
# Recovery fields, thanks to Kato Atsushi # Recovery fields, thanks to Kato Atsushi
if ($alert_mode == 0) { if ($alert_mode == 0) {
# Field 1 is a special case where [RECOVER] prefix is not added even when it is defined # Field 1 is a special case where [RECOVER] prefix is not added even when it is defined
$field1 = $alert->{'field1_recovery'} ne "" ? $alert->{'field1_recovery'} : $field1; $field1 = $alert->{'field1_recovery'} ? $alert->{'field1_recovery'} : $field1;
$field1 = $action->{'field1_recovery'} ne "" ? $action->{'field1_recovery'} : $field1; $field1 = $action->{'field1_recovery'} ? $action->{'field1_recovery'} : $field1;
$field2 = $field2 ne "" ? "[RECOVER]" . $field2 : ""; $field2 = $field2 ? "[RECOVER]" . $field2 : "";
$field2 = $alert->{'field2_recovery'} ne "" ? $alert->{'field2_recovery'} : $field2; $field2 = $alert->{'field2_recovery'} ? $alert->{'field2_recovery'} : $field2;
$field2 = $action->{'field2_recovery'} ne "" ? $action->{'field2_recovery'} : $field2; $field2 = $action->{'field2_recovery'} ? $action->{'field2_recovery'} : $field2;
$field3 = $field3 ne "" ? "[RECOVER]" . $field3 : ""; $field3 = $field3 ? "[RECOVER]" . $field3 : "";
$field3 = $alert->{'field3_recovery'} ne "" ? $alert->{'field3_recovery'} : $field3; $field3 = $alert->{'field3_recovery'} ? $alert->{'field3_recovery'} : $field3;
$field3 = $action->{'field3_recovery'} ne "" ? $action->{'field3_recovery'} : $field3; $field3 = $action->{'field3_recovery'} ? $action->{'field3_recovery'} : $field3;
$field4 = $field4 ne "" ? "[RECOVER]" . $field4 : ""; $field4 = $field4 ? "[RECOVER]" . $field4 : "";
$field4 = $alert->{'field4_recovery'} ne "" ? $alert->{'field4_recovery'} : $field4; $field4 = $alert->{'field4_recovery'} ? $alert->{'field4_recovery'} : $field4;
$field4 = $action->{'field4_recovery'} ne "" ? $action->{'field4_recovery'} : $field4; $field4 = $action->{'field4_recovery'} ? $action->{'field4_recovery'} : $field4;
$field5 = $field5 ne "" ? "[RECOVER]" . $field5 : ""; $field5 = $field5 ? "[RECOVER]" . $field5 : "";
$field5 = $alert->{'field5_recovery'} ne "" ? $alert->{'field5_recovery'} : $field5; $field5 = $alert->{'field5_recovery'} ? $alert->{'field5_recovery'} : $field5;
$field5 = $action->{'field5_recovery'} ne "" ? $action->{'field5_recovery'} : $field5; $field5 = $action->{'field5_recovery'} ? $action->{'field5_recovery'} : $field5;
$field6 = $field6 ne "" ? "[RECOVER]" . $field6 : ""; $field6 = $field6 ? "[RECOVER]" . $field6 : "";
$field6 = $alert->{'field6_recovery'} ne "" ? $alert->{'field6_recovery'} : $field6; $field6 = $alert->{'field6_recovery'} ? $alert->{'field6_recovery'} : $field6;
$field6 = $action->{'field6_recovery'} ne "" ? $action->{'field6_recovery'} : $field6; $field6 = $action->{'field6_recovery'} ? $action->{'field6_recovery'} : $field6;
$field7 = $field7 ne "" ? "[RECOVER]" . $field7 : ""; $field7 = $field7 ? "[RECOVER]" . $field7 : "";
$field7 = $alert->{'field7_recovery'} ne "" ? $alert->{'field7_recovery'} : $field7; $field7 = $alert->{'field7_recovery'} ? $alert->{'field7_recovery'} : $field7;
$field7 = $action->{'field7_recovery'} ne "" ? $action->{'field7_recovery'} : $field7; $field7 = $action->{'field7_recovery'} ? $action->{'field7_recovery'} : $field7;
$field8 = $field8 ne "" ? "[RECOVER]" . $field8 : ""; $field8 = $field8 ? "[RECOVER]" . $field8 : "";
$field8 = $alert->{'field8_recovery'} ne "" ? $alert->{'field8_recovery'} : $field8; $field8 = $alert->{'field8_recovery'} ? $alert->{'field8_recovery'} : $field8;
$field8 = $action->{'field8_recovery'} ne "" ? $action->{'field8_recovery'} : $field8; $field8 = $action->{'field8_recovery'} ? $action->{'field8_recovery'} : $field8;
$field9 = $field9 ne "" ? "[RECOVER]" . $field9 : ""; $field9 = $field9 ? "[RECOVER]" . $field9 : "";
$field9 = $alert->{'field9_recovery'} ne "" ? $alert->{'field9_recovery'} : $field9; $field9 = $alert->{'field9_recovery'} ? $alert->{'field9_recovery'} : $field9;
$field9 = $action->{'field9_recovery'} ne "" ? $action->{'field9_recovery'} : $field9; $field9 = $action->{'field9_recovery'} ? $action->{'field9_recovery'} : $field9;
$field10 = $field10 ne "" ? "[RECOVER]" . $field10 : ""; $field10 = $field10 ? "[RECOVER]" . $field10 : "";
$field10 = $alert->{'field10_recovery'} ne "" ? $alert->{'field10_recovery'} : $field10; $field10 = $alert->{'field10_recovery'} ? $alert->{'field10_recovery'} : $field10;
$field10 = $action->{'field10_recovery'} ne "" ? $action->{'field10_recovery'} : $field10; $field10 = $action->{'field10_recovery'} ? $action->{'field10_recovery'} : $field10;
} }
$field1 = decode_entities ($field1); $field1 = $field1 ? decode_entities($field1) : "";
$field2 = decode_entities ($field2); $field2 = $field2 ? decode_entities($field2) : "";
$field3 = decode_entities ($field3); $field3 = $field3 ? decode_entities($field3) : "";
$field4 = decode_entities ($field4); $field4 = $field4 ? decode_entities($field4) : "";
$field5 = decode_entities ($field5); $field5 = $field5 ? decode_entities($field5) : "";
$field6 = decode_entities ($field6); $field6 = $field6 ? decode_entities($field6) : "";
$field7 = decode_entities ($field7); $field7 = $field7 ? decode_entities($field7) : "";
$field8 = decode_entities ($field8); $field8 = $field8 ? decode_entities($field8) : "";
$field9 = decode_entities ($field9); $field9 = $field9 ? decode_entities($field9) : "";
$field10 = decode_entities ($field10); $field10 = $field10 ? decode_entities($field10) : "";
# Get group info # Get group info
my $group = undef; my $group = undef;