need help with website check notification when all is OK

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
a31modela
Posts: 18
Joined: Thu Jun 24, 2010 12:40 pm

need help with website check notification when all is OK

Post by a31modela »

Just got a request from our new CIO, he want an nagios check to check our web page every 4 hours and wants to get an email verifying the site is up. I have been using the check_website_response plugin for a few years and it works fine. to tell me when there is a problem. Cant seem to figure out how to tweak the check to only email when the site is up. Didn't see anything possible with the notification options either. I believe an R option would only tell you its back up after a problem.

Is there an easy way I can check the website every 4 hours and tell the CIO its working?

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

Re: need help with website check notification when all is OK

Post by dwhitfield »

Reports are an XI function and sound like what you need.

That said, you'll notice at http://nagios-plugins.org/doc/guidelines.html that an OK state corresponds to a 0. You could set up a script to send an email if the state is 0. You could run that script every four hours in cron.

Please let us know if you have any additional questions.
a31modela
Posts: 18
Joined: Thu Jun 24, 2010 12:40 pm

Re: need help with website check notification when all is OK

Post by a31modela »

thanks for the quick response. not sure where I would verify the current status as 0 from. would I grep the nagios.log?

BTW, I am using nagios core

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

Re: need help with website check notification when all is OK

Post by rkennedy »

From the CLI, something like this -

Code: Select all

[root@centos7x64 libexec]# ./check_http -H google.com && echo $?
HTTP OK: HTTP/1.1 301 Moved Permanently - 559 bytes in 0.136 second response time |time=0.136486s;;;0.000000 size=559B;;;0
0
Will show an OK state. (echo $? does this)

This will show us a critical state.

Code: Select all

[root@centos7x64 libexec]# ./check_http -H google.aaa
Name or service not known
HTTP CRITICAL - Unable to open TCP socket
[root@centos7x64 libexec]# echo $?
2
If you script can run check_http with your specific parameters, check what $? is equal to, and email accordingly - this should work.

If you want to go the Nagios route, take a look at https://assets.nagios.com/downloads/nag ... 1444063497 which may help with a creative way to get the check going. Negate will allow you to flip the status from CRIT -> OK, or OK -> CRIT. What I picture in your world, would be a check running with negate -o CRITICAL, and then a time period set to only allow the check to run every 4 hours. Here's an example of negate -

Code: Select all

[root@centos7x64 libexec]# ./negate -o CRITICAL ./check_http -H google.com
HTTP OK: HTTP/1.1 301 Moved Permanently - 559 bytes in 0.065 second response time |time=0.065478s;;;0.000000 size=559B;;;0
[root@centos7x64 libexec]# echo $?
2
Former Nagios Employee
Locked