X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=contrib%2Fexec-nagios.px;h=b26981fb32c7687507ae1690a53ceefa29ca6984;hp=3a8472413c53da140aad6d0c749628b23ad57d29;hb=f558b0dae60f18b6596d596cdcebb913756ce9f1;hpb=89783745dc59079eab34e0c52de6e5e972f50eb2 diff --git a/contrib/exec-nagios.px b/contrib/exec-nagios.px index 3a847241..b26981fb 100755 --- a/contrib/exec-nagios.px +++ b/contrib/exec-nagios.px @@ -88,6 +88,8 @@ with the C). =back +=back + =cut sub handle_config_addtype @@ -123,8 +125,20 @@ sub handle_config_script } else { - $opts->{'script'} = $script; - push (@$Scripts, $opts); + if (ref ($opts) eq 'ARRAY') + { + for (@$opts) + { + my $opt = $_; + $opt->{'script'} = $script; + push (@$Scripts, $opt); + } + } + else + { + $opts->{'script'} = $script; + push (@$Scripts, $opts); + } } } # for (keys %$scripts) } # handle_config_script @@ -221,6 +235,7 @@ sub handle_performance_data my $type = shift; my $time = shift; my $line = shift; + my $ident = "$host/$plugin-$pinst/$type-$tinst"; my $tinst; my $value; @@ -236,7 +251,9 @@ sub handle_performance_data return; } - print "PUTVAL $host/$plugin-$pinst/$type-$tinst interval=$Interval ${time}:$value\n"; + $ident =~ s/"/\\"/g; + + print qq(PUTVAL "$ident" interval=$Interval ${time}:$value\n); } sub execute_script @@ -281,7 +298,7 @@ sub execute_script if ($perfdata) { - push (@serviceperfdata, split (' ', $perfdata)); + push (@serviceperfdata, split (' ', $perfdata)); } $state = 1; @@ -296,8 +313,8 @@ sub execute_script if ($perfdata) { - push (@serviceperfdata, split (' ', $perfdata)); - $state = 2; + push (@serviceperfdata, split (' ', $perfdata)); + $state = 2; } } else # ($state == 2) @@ -335,7 +352,7 @@ sub execute_script for (@serviceperfdata) { handle_performance_data ($host, 'nagios', $pinst, $script->{'type'}, - $time, $_); + $time, $_); } } } # execute_script