string check via nagios

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
dxUser
Posts: 3
Joined: Wed Feb 16, 2011 10:28 am

string check via nagios

Post by dxUser »

Hello together,

I'm using Nagios® Core™ Version 3.2.1.
With nagios I'm monitoring some systems and also some websites.
Now I'm looking for a chance to scan for "strings" on the monitored websites.

E.g: On a website there is the string "Hello World", so I want to proof with nagios, if this string is available.

Does nagios already have an plugin or other function to realize this?


Greetings
dxUser
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: string check via nagios

Post by tonyyarusso »

See the --string switch to the check_http plugin (part of the official nagios-plugins package).
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
dxUser
Posts: 3
Joined: Wed Feb 16, 2011 10:28 am

Re: string check via nagios

Post by dxUser »

I defined the following service:

define service{
host_name hostname
service_description websitesearch
check_command check_http!url-adress!"string"
max_check_attempts 4
normal_check_interval 4
retry_check_interval 3
check_period 24x7
notification_interval 60
notification_period 24x7
notification_options w,c,r
}
if I call from the shell:

./check_http -H url-adress -s "stringnotavailable"

this message is shown:

HTTP CRITICAL: HTTP/1.1 200 OK - string not found - 26654 bytes in 1.030 second response time |time=1.029727s;;;0.000000 size=26654B;;;0

Because the HTTP CRITICAL is OK I don't get an error in the Service Status view, but I should got an error, then the string is not found.

Any ideas?
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: string check via nagios

Post by tonyyarusso »

Are you using the check_http from the official Nagios Plugins package? What version? (That's different output than I get.)
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
Kerflumpre
Posts: 30
Joined: Fri Apr 22, 2011 6:50 pm

Re: string check via nagios

Post by Kerflumpre »

I'm having some trouble getting the string check to work as well. I have no trouble from the command line issuing the following command:

Code: Select all

check_http -H www.domain.com -t 5 -s "string"
But if I add it to a cfg file I get the following results with these different configs:

This config returns "HTTP CRITICAL - string not found "

Code: Select all

define service{
	use		generic-service
	host_name		www.domain.com
	service_description	HTTP
	check_command	check_http!-H www.domain.com -t 5 -s "string"
	}
This config returns "HTTP OK HTTP/1.1 200 OK", but it doesn't validate the string, I can put anything in there.

Code: Select all

define service{
	use		generic-service		
	host_name		www.domain.com
	service_description	HTTP
	check_command	check_http!www.domain.com!"string"
	}
This config returns "HTTP CRITICAL - string not found "

Code: Select all

define service{
	use		generic-service		
	host_name		www.domain.com
	service_description	HTTP
        check_command	check_http!-u / -t 5 -s "string"
	}
I've tried a few more different variations, but these are the major ones. Any insight into why I'm not getting it right would be appreciated. I've tried this on both 3.2.1 and 3.2.3
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: string check via nagios

Post by niebais »

Kerflumpre wrote:I'm having some trouble getting the string check to work as well. I have no trouble from the command line issuing the following command:

Code: Select all

check_http -H www.domain.com -t 5 -s "string"

I've tried a few more different variations, but these are the major ones. Any insight into why I'm not getting it right would be appreciated. I've tried this on both 3.2.1 and 3.2.3

Here's an example of how we do regex with check_http:

Here's the command: $USER1$/check_http -H $HOSTNAME$ -u '$ARG1$' -p $ARG2$ -t 60 -l -w 25 -c 30 -R '$ARG3$' -P '$ARG4$'

-u is the uri
-p is the port (usually 80)
-R is the regex statement (like OK or hello world)
and -P is optional, but you can put in your parameters here. Seems to work really well.
Kerflumpre
Posts: 30
Joined: Fri Apr 22, 2011 6:50 pm

Re: string check via nagios

Post by Kerflumpre »

I was able to get it working using the following:

Code: Select all

define service{
	use			generic-service
	host_name		www.domain.com
	service_description	HTTP
	check_command		check_http!-H www.domain.com -s "string"
	}
I used the following for SSL sites:

Code: Select all

define service{
	use			generic-service
	host_name		www.domain.com
	service_description	HTTPS
	check_command		check_http!-H www.domain.com -S -s "string"
	}
Locked