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
need help with website check notification when all is OK
-
- 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
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.
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.
Re: need help with website check notification when all is OK
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
BTW, I am using nagios core
thanks,
Steve
Re: need help with website check notification when all is OK
From the CLI, something like this -
Will show an OK state. (echo $? does this)
This will show us a critical state.
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]# ./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
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 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