our $TypeMap = {};
our $NRPEMap = {};
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);
=head1 CONFIGURATION
-This script reads it's configuration from F</etc/exec-nagios.conf>. The
+This script reads its configuration from F</etc/exec-nagios.conf>. The
configuration is read using C<Config::General> which understands a Apache-like
config syntax, so it's very similar to the F<collectd.conf> syntax, too.
my $type = shift;
my $time = shift;
my $line = shift;
+ my $ident = "$host/$plugin-$pinst/$type-$tinst";
my $tinst;
my $value;
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
my $time = time ();
my $script = shift;
my @args = ();
- my $host = hostname () || 'localhost';
+ my $host = $Hostname || hostname () || 'localhost';
my $state = 0;
my $serviceoutput;
close ($fh);
# Save the exit status of the check in $state
- $state = $?;
+ $state = $? >> 8;
if ($state == 0)
{