Page 1 of 1
string check via nagios
Posted: Tue Apr 12, 2011 3:57 am
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
Re: string check via nagios
Posted: Tue Apr 12, 2011 10:27 am
by tonyyarusso
See the --string switch to the check_http plugin (part of the official nagios-plugins package).
Re: string check via nagios
Posted: Thu Apr 14, 2011 4:28 am
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?
Re: string check via nagios
Posted: Thu Apr 14, 2011 12:07 pm
by tonyyarusso
Are you using the check_http from the official Nagios Plugins package? What version? (That's different output than I get.)
Re: string check via nagios
Posted: Fri Apr 22, 2011 7:17 pm
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
Re: string check via nagios
Posted: Wed Apr 27, 2011 5:25 pm
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.
Re: string check via nagios
Posted: Wed Apr 27, 2011 6:00 pm
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"
}