Checking a web page for 403 error

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
SavaSC
Posts: 238
Joined: Wed Feb 23, 2011 4:49 pm

Checking a web page for 403 error

Post by SavaSC »

Hello,

We have a web page that management wants monitored to make sure it is up and can be accessed from a particular application server. The problem is that this webpage requires a login and the Powers That Be don't want to give the account we use for monitoring access to it. I thought "Fine, I'll just have Nagios check if a 403 error is returned."

Unfortunately, it seems that because it is an error code, Nagios insists upon reporting it as a Warning level problem even though it is receiving the expected result.

Here is the result:

Code: Select all

 /usr/local/nagios/libexec/check_http -H <ServerName> -u <https://URL> -e 403 
HTTP WARNING: Status line output matched "403" - HTTP/1.1 403 Forbidden - 1412 bytes in 0.083 second response time |time=0.082799s;;;0.000000 size=1412B;;;0 
Any suggestions on how I can have Nagios return an OK result from an expected 403 page?

Thanks!
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Checking a web page for 403 error

Post by dwhitfield »

Yes, you can you the 'negate' plugin in conjunction with your check command. This docs explains how to do it: https://assets.nagios.com/downloads/nag ... ios-XI.pdf
The Negate plugin allows for any standard plugin output to be reversed and is very useful with hosts or services that are expected to be in a Critical or Warning state but you wish to show them as OK. This function can be used for the opposite effect (i.e. showing a CRITICAL state when the actual state is OK)
SavaSC
Posts: 238
Joined: Wed Feb 23, 2011 4:49 pm

Re: Checking a web page for 403 error

Post by SavaSC »

Sweet! That worked! I used this command:

Code: Select all

$USER1$/negate -w 0 $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$ -e $ARG2$ $ARG3$ 
You can close this.
Locked