Page 1 of 1

Using the "Search for Content" String in the Webserver Wiz

Posted: Sat Jun 25, 2011 4:43 am
by sievers
Hello,

we have been given the task to monitor a website (hobit) which in turns monitors other websites. Now in itself this would be simple because the website only monitors RED or GREEN status (with a gif image)

On the website in question there are 50+ services, all with the same RED or GREEN gif. What I want to do is just copy some code from the HTML text and use that as content string for example

Code: Select all

"/hobbit-cgi/bb-hostsvc.sh?HOST=www.xxxxxxxxx.de&SERVICE=conn"><IMG SRC="/hobbit/gifs/static/green.gif"
would be the content string I input into the wizard. If the HTML code changes to red.gif, I get a NAGIOS escalation.

. I need the http://www.xxxxxx.de as reference since there are mulitple websites, otherwise it would just check the HTML code for green.gif

The problem now is that when I do this I get an NAGIOS error. And when I look at the configuration string it chopped off either by ; or "

Is there any way I can get the content string as a whole into the wizard with all the sympols ";>< etc.?

Thanks for your help

EDIT: Forgot to add that we are using NAGIOS XI 2011 R1.1

Re: Using the "Search for Content" String in the Webserver W

Posted: Mon Jun 27, 2011 10:55 am
by nscott
Yes, you will need to go into the core config manager and change the service. In the command string you'll need to find context string that nagios is looking for and replace the double quotes that wrap the string with singles. That should work.

Re: Using the "Search for Content" String in the Webserver W

Posted: Tue Jun 28, 2011 8:43 am
by sievers
thank you so much it worked,


now I have my next question. Is it possible to monitor multiple content states with the same check.

For example in hobbit there is also a yellow Status, with yellow.gif.

Now if the status in hobbit changes to yellow it would turn red in Nagios since the content string would not find green.gif.

is there any way of telling nagios to stay status "OK" if the hobbit status is yellow.gif or green.gif , this would ensure that NAGIOS only escalates if the content on the hobbit server goes to red.gif (Basically like an OR Statement)

Re: Using the "Search for Content" String in the Webserver W

Posted: Tue Jun 28, 2011 9:44 am
by mguthrie
You should be able to do this with a regular expression match, which is available in the website wizard. I'm not a master of regular expressions myself, but it would be something like "/(yellow|green).gif/", but that's probably not quite right.

Re: Using the "Search for Content" String in the Webserver W

Posted: Thu Jun 30, 2011 3:35 am
by sievers
Can perhaps one of your collegues help with the regular expressio?

Re: Using the "Search for Content" String in the Webserver W

Posted: Thu Jun 30, 2011 1:44 pm
by agriffin
Try this as a regular expression:

Code: Select all

"\/hobbit-cgi\/bb-hostsvc\.sh\?HOST=www\.xxxxxxxxx\.de&SERVICE=conn"><IMG SRC="\/hobbit\/gifs\/static\/(yellow|green)\.gif"
You will probably need to change some double quotes to single quotes again afterwards.

Re: Using the "Search for Content" String in the Webserver W

Posted: Mon Jul 04, 2011 1:11 am
by sievers
Hi,

I don“t understand the regular expression syntax.
Why put you all the commands in \/hobbit\/gifs\/static\ ???

Is is possibe to set the string like this?

Code: Select all

HOST=www.xxxx.de&SERVICE=http"><IMG SRC="/hobbit/gifs/static/(yellow|blue|green).gif
regards

Re: Using the "Search for Content" String in the Webserver W

Posted: Tue Jul 05, 2011 11:08 am
by agriffin
Yes, that should work too. Many tools using regular expressions have a special meaning for a forward slash character, so I escaped it out of habit (by putting a backslash in front of it). It's also a good idea in general to escape periods as well, since periods in regular expressions match any character. In this case it may not matter, though.