Skip to content

Commit

Permalink
* munin-limits: Check if $children is undef before using it as a arra…
Browse files Browse the repository at this point in the history
…y reference. Fixes #762
  • Loading branch information
Nicolai Langfeldt committed Nov 24, 2009
1 parent 2aa9c32 commit d127ed8
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions master/lib/Munin/Master/LimitsOld.pm
Expand Up @@ -476,17 +476,22 @@ sub generate_service_message {
DEBUG "[DEBUG] generating service message: "
. join('::', @{munin_get_node_loc($hash)});

foreach my $field (
@{munin_get_children(
munin_get_node(\%notes, munin_get_node_loc($hash)))}
) {
if (defined $field->{"state"}) {
push @{$stats{$field->{"state"}}}, munin_get_node_name($field);
if ($field->{"state"} eq "ok") {
push @{$stats{"foks"}}, munin_get_node_name($field);
}
}
my $children =
munin_get_children(
munin_get_node(\%notes,
munin_get_node_loc($hash)));

if ( defined($children) ) {
foreach my $field (@$children) {
if (defined $field->{"state"}) {
push @{$stats{$field->{"state"}}}, munin_get_node_name($field);
if ($field->{"state"} eq "ok") {
push @{$stats{"foks"}}, munin_get_node_name($field);
}
}
}
}

$hash->{'cfields'} = join " ", @{$stats{'critical'}};
$hash->{'wfields'} = join " ", @{$stats{'warning'}};
$hash->{'ufields'} = join " ", @{$stats{'unknown'}};
Expand Down

0 comments on commit d127ed8

Please sign in to comment.