hi,
recently I tried to write my own plugin in perl. it works fine, but I can’t make it run with NRPE. I’m new in this, can’t find solution. I’m not using embedded perl. I want my script to simply check uptime on an unix machine. here’s the code:
#! /usr/bin/perl -w
#simple perl script for checking uptime on the unix machine
#
use strict;
use Getopt::Long;
use Pod::Usage;
use lib '/usr/local/nagios/libexec/';
use utils qw(%ERRORS);
use vars qw($opt_V $opt_h);
sub nagexit($$);
#Getopt::Long::Configure('bundling');
GetOptions("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h);
if ($opt_V) {
print "check_uptime.pl version 0.001 by michas\n";
exit();
}
if ($opt_h) {
print "call with no parameters for normal use;\n";
print "-V for version\n";
print "-h for this help\n";
exit();
}
my $uptime=`uptime`;
#print "$uptime\n";
nagexit('OK', "$uptime");
sub nagexit($$) {
my $errlevel = shift;
my $string = shift;
print "$errlevel: $string";
exit $ERRORS{$errlevel};
}
master server service definition:
define service{
host_name new
service_description uptime
check_command check_nrpe!check_uptime
}
and command on a “new” host (virtualized ubuntu-jeos):
command[check_uptime]=/usr/lib/nagios/libexec/check_uptime.pl
results on a “new” machine:
root# /usr/local/nagios/libexec/check_uptime.pl
OK: 12:46:16 up 2 days, 4:43, 2 users, load average: 0.00, 0.00, 0.00
and on a master server:
root# /usr/local/nagios/libexec/check_nrpe -H 192.168.4.119 -c check_uptime
NRPE: Unable to read output
any idea?
greetings.