Subject: | Undefined value in Nagios::ServiceGroup::set_members |
This is based on the code from github, modified on 20 Feb 2009.
I tried using Nagios::Object::Config to read in my nagios 2.0
objects.cache file. It worked well (thanks!), but I found a small
error in the parsing code. The code generated a series of errors
like:
Use of uninitialized value in array dereference at lib/Nagios/Object.pm
line 1064, <GEN1> line 472
(the line number is from my edited version of the file, so it won't
match yours...)
Investigating further, it turns out the members field of
Nagios::ServiceGroup objects is never being initialized.
The fix is a one line change:
$ diff -c Object.pm.orig Object.pm
*** Object.pm.orig Thu Mar 5 16:33:36 2009
--- Object.pm Thu Mar 5 16:30:44 2009
***************
*** 1056,1061 ****
--- 1056,1063 ----
}
# also, before resolution, append to the list rather than replace it
else {
+
+ $self->{members} = [] if ! defined($self->{members});
@members = @{ $self->{members} };
foreach my $item ( @_ ) {
if ( ref($item) eq 'ARRAY' && @$item == 2 ) {