Page 1 of 1

Checking a web page for 403 error

Posted: Tue May 23, 2017 10:03 am
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!

Re: Checking a web page for 403 error

Posted: Tue May 23, 2017 11:35 am
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)

Re: Checking a web page for 403 error

Posted: Tue May 23, 2017 1:12 pm
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.