Executing a script based on text from a web page

Martin Melin mmelin at gmail.com
Fri Aug 6 16:43:47 CEST 2010


On Fri, Aug 6, 2010 at 4:16 PM, Joseph Devaney
<jdevaney at blackducksoftware.com> wrote:
> I know that nagios can monitor pages for certain text on that page to verify
> that its there.  In our organization we have several monitors like this
> currently setup and they work well for us.  I want to take this operability
> and apply it to a webpage that only appears when there is a server error and
> have it kick off a script to restart a service.
> This is for a website within the company.  When there are too many mysql
> connections, the site itself will not be displayed but will display a
> friendly error for us to perform a flush of the hosts.  This error doesnt
> occur often and when it does occur, it doesn't always happen when someone is
> awake to address it.  Basically what I want to happen is for nagios to
> monitor a website and if/when this error appears (I will set the
> check_command to look for the right text) nagios will execute a script to
> restart that service.  99% of the time, the site will be up and functioning
> as it should be, so I am not sure how to write this one up without giving a
> false positive on our monitors.
> Any thoughts on how to implement this?
>

This should be fairly simple to do with a service-specific event
handler http://nagios.sourceforge.net/docs/3_0/eventhandlers.html and
a check that uses check_http to look for that error message. I think
check_http has options for inverting the default check behavior (i.e.
return CRITICAL if a string is found) but otherwise you can use negate
to accomplish the same thing.

I may not be understanding your question fully though - how would you
risk creating a false positive here? Do you want to restart the
service every time the error message appears on the internal webpage,
or do you also want to check if the site is down before restarting?

Best regards
Martin Melin

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list