X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=contrib%2Fexec-nagios.px;h=4b112f95139aa97fc0b04b3044c528f3218837f8;hb=50c6b81549e3239034f71f00ff7dde4c6a8767e5;hp=938721fc55624977fa89d5ea3a1d289531573b6d;hpb=b34e15480992d9433a0e3fda47b5f6d387bfda5e;p=collectd.git diff --git a/contrib/exec-nagios.px b/contrib/exec-nagios.px index 938721fc..4b112f95 100755 --- a/contrib/exec-nagios.px +++ b/contrib/exec-nagios.px @@ -24,7 +24,8 @@ use Regexp::Common ('number'); our $ConfigFile = '/etc/exec-nagios.conf'; our $TypeMap = {}; our $Scripts = []; -our $Interval = 300; +our $Interval = defined ($ENV{'COLLECTD_INTERVAL'}) ? (0 + $ENV{'COLLECTD_INTERVAL'}) : 300; +our $Hostname = defined ($ENV{'COLLECTD_HOSTNAME'}) ? $ENV{'COLLECTD_HOSTNAME'} : ''; main (); exit (0); @@ -235,6 +236,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; @@ -250,7 +252,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 @@ -260,7 +264,7 @@ sub execute_script my $time = time (); my $script = shift; my @args = (); - my $host = hostname () || 'localhost'; + my $host = $Hostname || hostname () || 'localhost'; my $state = 0; my $serviceoutput;