Hi all,
I just wrote a script to check the monitor of my cgi scripts and integrate it into nagios so that it can notify me when error occurs.
The problem is that when I run it on the command line it works perfectly but in nagios it gives a “No Output error” what am I doing wrong?
Here is a copy of the script and the nagios config below:
SCRIPT:
#!/usr/bin/perl
use strict;
########## Configure Section ############
my $url = $ARGV[0];
my $warning = $ARGV[1];
my $critical = $ARGV[2];
my $wget = wget -nv --spider -o output.nagios $url
-$warning -$critical;
my $output_file = “output.nagios”;
######## Program Section #############
open(DAT, $output_file) || die (“Could not open file!”);
my @output = ;
close(DAT);
if (my @ok = grep(/OK/,@output)) {
print “HTTP: @ok\n”;
exit 0;
}
if ($critical == 1){
my @critical = grep(/ERROR/,@output);
print “CRITICAL: HTTP: @critical\n”;
exit 1;
}# end if
print “Warning: @output\n”;
NAGIOS config:
SERVICE:
#########################################################
Checking URL
########################################################
define service{
host_name url.com
service_description check-url
check_command check_url.pl!URL!1
max_check_attempts 5
normal_check_interval 5
retry_check_interval 3
check_period 24x7
notification_interval 0
notification_period 24x7
notification_options c,r
contact_groups web-admins
}
##########################################################
CHECKCOMMAND:
check_url command definition
define command{
command_name check_url
command_line $USER1$/check_url.pl $HOSTADDRESS$ $ARG1$ $ARG2$
}
Thank you for your help.