Monitor specific http text

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
Also
Posts: 10
Joined: Thu Jun 02, 2016 12:59 pm

Monitor specific http text

Post by Also »

Hi to all,
all tips will be appreciated, and apologize for my bad english..
I've succesfully installed Nagios Core 4.1.1, and now I need to monitor a specif text in a specific site.
I found a third party plug-in named check_http_content.
I put it in /usr/lib/nagios/plugins, and if i do:
./check_http_content -U http://google.com -m "google" -t 30
I receive:
CONTENT OK: EXPR FOUND

This is the help plug-in:
Retrieve an http/s URL and looks in its output for a given text.
Returns CRITICAL is not found, OK if found, UNKNOWN otherwise.

--help shows this message
--version shows version information

-U URL to retrieve (http or https)
-m <text> Text to match in the output of the URL
-t Timeout in seconds to wait for the URL to load. If the page fails to load,
$plugin_name will exit with UNKNOWN state (default 60)
(I don't know if I can put the link of the plug-in)

Then I add in
/usr/local/nagios/etc/objects/commands.cfg
this line:
define command{
command_name check_http_content
command_line $USER1$/check_http_content -U $ARG1$ -m $ARG2$ -t $ARG3$
}

Then I add in
/usr/local/nagios/etc/servers
this simple host in:
define host {
use linux-server
host_name google.com
address google.com
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}

define service{
use generic-service
host_name google.com
service_description monitor http site
check_command check_http_content -U http://google.com -m "google" -t 30
notifications_enabled 0
}

if I try:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
the answer is:
Error: Service check command 'check_http_content -U http://google.com -m "google" -t 30' specified in service 'sem.i' for host 'google.com' not defined anywhere!

What I am missing?

My goal is to monitor my site to make sure everything works and nobody has changed anything.

Thanks to all those who will try to help me, and also to all those who lost time to read my loooong post
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Monitor specific http text

Post by lmiltchev »

Try changing your service definition to this:

Code: Select all

define service{
use generic-service
host_name google.com
service_description monitor http site
check_command check_http_content!http://google.com!"google"!30
notifications_enabled 0
}
then verify configuration:

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Did this help?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Also
Posts: 10
Joined: Thu Jun 02, 2016 12:59 pm

Re: Monitor specific http text

Post by Also »

Quick and perfect!
This help very much!

Thank you!!
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Monitor specific http text

Post by mcapra »

Is it alright if we lock this thread and mark the issue as resolved?
Former Nagios employee
https://www.mcapra.com/
Also
Posts: 10
Joined: Thu Jun 02, 2016 12:59 pm

Re: Monitor specific http text

Post by Also »

Yes,
thanks again!
Locked