Service URL Monitoring

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
MOHAMMAD1412
Posts: 9
Joined: Sat Feb 20, 2016 8:39 am

Service URL Monitoring

Post by MOHAMMAD1412 »

Hi All,

We are monitoring Service URL status using Nagios. Currently application has been upgraded, once after the upgrade I can see lot of alerts getting triggered stating that "WEB SITE is having problems".

Below is the command used to check the URL Status

/usr/bin/curl -A "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" --basic "http://xx-xxxx-xxx.xxx.xxx.com" | /bin/grep xxxx

Upgraded application version supports IE 11, so I have corrected the above command with the new IE version but still its showing in Warning status.

/usr/bin/curl -A "Mozilla/4.0 (compatible; MSIE 11.0; Windows NT 6.0)" --basic "http://xx-xxxx-xxx.xxx.xxx.com" | /bin/grep xxxx

Please provide your comments.

Thanks In Advance
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Service URL Monitoring

Post by rkennedy »

It doesn't look like you're using our check_http plugin. What are you using for warning / critical thresholds?
Former Nagios Employee
MOHAMMAD1412
Posts: 9
Joined: Sat Feb 20, 2016 8:39 am

Re: Service URL Monitoring

Post by MOHAMMAD1412 »

Yes check_http plugin is not used, we are using Perl script for check the Application URL status.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Service URL Monitoring

Post by rkennedy »

As you're using a custom script, we do not know everything that is going into it. Can you post the perl script here?
Former Nagios Employee
MOHAMMAD1412
Posts: 9
Joined: Sat Feb 20, 2016 8:39 am

Re: Service URL Monitoring

Post by MOHAMMAD1412 »

Hi,

Please find the required parameters

Service.cfg
define service{
use generic-service
host_name xx-xxxxx-xxx
service_description HTTP-TEST
normal_check_interval 30
contact_groups xxxx-xxxx
notification_interval 60
notification_options c,r,w,u
check_command generic-http-check!test
}

define command{
command_name generic-http-check
command_line /usr/local/nagios/libexec/generic-http-chk.pl -H $HOSTNAME$ -f $ARG1$
}

Command used by the script - /usr/bin/curl -A "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" --basic "http://xx-xxxxx-xxx.xxx.xxx.xxx" | /bin/grep Test

Script

#! /usr/bin/perl -w
#
# usage:
#
use POSIX;
use strict;
use Getopt::Long; declaration of Getopt command
use vars qw($opt_H $opt_f );
use vars qw($PROGNAME);

use lib "/usr/local/nagios/libexec" ;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);

sub print_help ();
sub print_usage ();

$PROGNAME = "generic-http-chk.pl";

$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';

Getopt::Long::Configure('bundling');
GetOptions
("H=s" => \$opt_H, "hostname=s" => \$opt_H,
"f=s" => \$opt_f, "filter=s" => \$opt_f);


($opt_f) || ($opt_f = shift) || ($opt_f = "FILTER OUT ALL BUT");


use strict;
my($status,$cmd,$output,$junk);
my @output;


$cmd = "/usr/local/bin/curl.$opt_f";

chop(@output=`$cmd`);
$status = $?;
$status = $?/256; # To get actual exit value, divide by 256
($output)=@output;
#print "$status\n";

if ($status==0) {
print "$opt_f WEB SITE is OK\n";
exit 0;
}
elsif ($status==1) {
print "$opt_f WEB SITE is having problems\n";
exit 1;
}
elsif ($status==2) {
print "$opt_f WEB SITE is in big trouble\n";
exit 2;
}
else {
print "@output\n";
exit 3;
}

Thanks
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Service URL Monitoring

Post by rkennedy »

I tried getting the script you posted to work, and was unable to. As you're using a custom plugin, we can't support everything.

With that said, the default check_http plugin does support a useragent with -A, will this plugin not work for you?
-A, --useragent=STRING
String to be sent in http header as "User Agent"
Former Nagios Employee
MOHAMMAD1412
Posts: 9
Joined: Sat Feb 20, 2016 8:39 am

Re: Service URL Monitoring

Post by MOHAMMAD1412 »

Hi All,

Updated the script resolved the issue.

Please close the thread.

Thanks
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Service URL Monitoring

Post by rkennedy »

Great to hear, marking this as resolved and closing it out.
Former Nagios Employee
Locked