projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
contrib/collection3: Add basic compatibility to mod_perl.
[collectd.git]
/
contrib
/
exec-nagios.px
diff --git
a/contrib/exec-nagios.px
b/contrib/exec-nagios.px
index
a9f4663
..
4b112f9
100755
(executable)
--- 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 $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);
main ();
exit (0);
@@
-88,6
+89,8
@@
with the C<exec-plugin>).
=back
=back
+=back
+
=cut
sub handle_config_addtype
=cut
sub handle_config_addtype
@@
-233,6
+236,7
@@
sub handle_performance_data
my $type = shift;
my $time = shift;
my $line = shift;
my $type = shift;
my $time = shift;
my $line = shift;
+ my $ident = "$host/$plugin-$pinst/$type-$tinst";
my $tinst;
my $value;
my $tinst;
my $value;
@@
-248,7
+252,9
@@
sub handle_performance_data
return;
}
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
}
sub execute_script
@@
-258,7
+264,7
@@
sub execute_script
my $time = time ();
my $script = shift;
my @args = ();
my $time = time ();
my $script = shift;
my @args = ();
- my $host = hostname () || 'localhost';
+ my $host =
$Hostname ||
hostname () || 'localhost';
my $state = 0;
my $serviceoutput;
my $state = 0;
my $serviceoutput;
@@
-293,7
+299,7
@@
sub execute_script
if ($perfdata)
{
if ($perfdata)
{
- push (@serviceperfdata, split (' ', $perfdata));
+
push (@serviceperfdata, split (' ', $perfdata));
}
$state = 1;
}
$state = 1;
@@
-308,8
+314,8
@@
sub execute_script
if ($perfdata)
{
if ($perfdata)
{
- push (@serviceperfdata, split (' ', $perfdata));
- $state = 2;
+
push (@serviceperfdata, split (' ', $perfdata));
+
$state = 2;
}
}
else # ($state == 2)
}
}
else # ($state == 2)
@@
-347,7
+353,7
@@
sub execute_script
for (@serviceperfdata)
{
handle_performance_data ($host, 'nagios', $pinst, $script->{'type'},
for (@serviceperfdata)
{
handle_performance_data ($host, 'nagios', $pinst, $script->{'type'},
- $time, $_);
+
$time, $_);
}
}
} # execute_script
}
}
} # execute_script