Using Nagios to check keyword?

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
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Using Nagios to check keyword?

Post by t3dus »

How do I get nagios to check a keyword on a domain or even a subdomain?

I tried the following which I stole from here:

Code: Select all

check_http -H twitter.com -u "/snapgeekphoto" -s "snapgeekphoto
But when I run checkconfig before restarting i get this error:

Code: Select all

# service nagios checkconfig
Running configuration check...

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
Error: Service check command 'check_http -H twitter.com -u "/snapgeekphoto" -s "snapgeekphoto"' specified in service 'PING' for host 'twitter.com/snapgeekphoto' not defined anywhere!
        Checked 58 services.
        Checked 31 hosts.
        Checked 2 host groups.
        Checked 0 service groups.
        Checked 2 contacts.
        Checked 1 contact groups.
        Checked 24 commands.
        Checked 5 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 31 hosts
        Checked 0 service dependencies
        Checked 14 host dependencies
        Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   1

***> One or more problems was encountered while running the pre-flight check...

     Check your configuration file(s) to ensure that they contain valid
     directives and data defintions.  If you are upgrading from a previous
     version of Nagios, you should be aware that some variables/definitions
     may have been removed or modified in this version.  Make sure to read
     the HTML documentation regarding the config files, as well as the
     'Whats New' section to find out what has changed.
Not exactly what i'm doing wrong but i want to be able to check keywords on websites.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Using Nagios to check keyword?

Post by mcapra »

That's generally the right idea, but not exactly the correct configuration. Can you post this specific service definition you're using as well as your command definition for check_http?

If I had the following command definition for check_http:

Code: Select all

define command {
       command_name                  		check_http_for_cool_guys
       command_line                  		$USER1$/check_http -H $HOSTADDRESS$ $ARG1$
}
And I wanted to leverage this command to check the contents of www.example.com to ensure the term established is there, I would need to make sure my check_command definition for my service matches the syntax for my defined command (check_http_for_cool_guys). Keep in mind, the name of the command doesn't always need to be the exact name of the script/plugin.

Code: Select all

define service {
	host_name			www.example.com
        ....
	service_description		Web Page Content
	check_command			check_http_for_cool_guys!-u "/" -s "established" 
        ....
	}	
Since my command definition is expecting only 1 argument (for $ARG1$), I simply add all the special check_http directives my check needs in as a single argument following the ! character for my service's check_command definition.
Former Nagios employee
https://www.mcapra.com/
Locked