check_http

Wow I am starting to feel like a complete idiot.

To the best of my knowledge I configured the Nagios server exactly as it said to do it on the Fedora quickstart page. I managed to configure the software to monitor localhost and a couple of computers on my local network.

Then I decided I would monitor some of my offsite webservers I host webpages on. This is were I hit a brick wall.

I thought I had followed the directions for the .cfg file exactly but no matter what I do it seems to crash the server when i go to restart.

I then decided to find were the plugins are with little or no luck so i typed in locate check_http. Nothing was found.

I reenstalled the plugins and again tried to locate check_http.

I resarted the nagios service and tried to run check_http -h as I saw in several of the posts but needless to say this did nothing.

Basically I want to run a config that will monitor an URL web site.

Any advice on what i might try next. I have hours into this and am hitting the point of frustration.

the check plugins are normally installed in the …nagios/libexec directory (usually /usr/local/nagios/libexec) so it should be there. “locate” will only find something if you run “updatedb” after adding whatever you are looking for.

I will go look now. I really do appreciate that. I am a long time windows guy but just begining to grasp this linux thing.

heh I know where your coming from :slight_smile:

OK I have the file but for whatever reason if I type in “check_http” I get nothing I also tried to type in “check_http -H” and it did not work either. this was run as root from within the …nagios/libexec directory

I then tried …nagios/libexec/check_http -H and I got what i had hoped to and that was a response from the program.

ok so i did" …nagios/libexec/check_http -w 5 -c 10 -H www.google.com" and I got back the response as the server being good.

Now that I can make this work I am completely and totally lost as to how to make the config work without crashing.

Does someone by chance have a .cfg file that worked for someithing like this or know of a website that explains it otherthen quick start. I am trying to follow the quick start for this and apparently am way to dense.

thanks a ton.

Ah, alrighty then, you’ve got the plugin - thats a good start chap, don’t lose hope just yet! BTW, bit of *nix that ppl rarely mention: to run something from the CLI from the directory in which it resides, you need to put a ./ in front, like

[root@localhost libexec]# ./check_http check_http: Could not parse arguments Usage: check_http -H <vhost> | -I <IP-address> -u <uri>] -p <port>] -w <warn time>] -c <critical time>] -t <timeout>] -L] -a auth] -f <ok | warn | critcal | follow>] -e <expect>] -s string] -l] -r <regex> | -R <case-insensitive regex>] -P string] -m <min_pg_size>:<max_pg_size>] -4|-6] -N] -M <age>] -A string] -k string] -S] -C <age>] -T <content-type>] [root@localhost libexec]#
If you run it with the full path, it isn’t neccessary (as you have found)

From here on in, to monitor your HTTP service it’s pretty much as described in nagios.sourceforge.net/docs/3_0/ … vices.html

To keep things nice and simple I suggest you create a ‘httptest.cfg’ in your nagios/etc/objects directory and put the bits and bobs in there. So what you need to do first is create your ‘host object’ which, at it’s simplest will look something like

define host{ use generic-host ; Inherit default values from a template host_name webserver ; The name we're giving to this host alias Some Web Server ; A longer name associated with the host address 192.168.1.50 ; IP address of the host }

Then, you need to define your service object, like

[blockquote]define service{
use generic-service ; Inherit default values from a template
host_name webserver
service_description HTTP
check_command check_http!-u someserver.com/index.html
}[/blockquote]

*Replacing the -u http…with the url of the web page you wish to check that is being served from the host server as you would put it in the address bar of your browser.

The ! symbol in the check_command line delimits your arguments as they appear for when they are passed through to the check command. What happens is, if you look in commands.cfg you will see a command object definition for check_http that finishes with $ARG1$. This is replaced by whatever comes after the !.. As we only have the one argument to satisfy, anything after the ! in the service definition becomes $ARG1$, therefore if your webpage has some basic authentication on it you can change it to “check_http!-u someserver.com/index.html -a username:Password” for example… Other checks may have multiple $ARGs in the command definition and you will no doubt become familiar with them in the future. When you define your service checks for these, you just use multiple !s, like “check_whatever!somearg!someotherarg!yetanother!etc”… anyway… I digress.

Next, make sure the permissions and ownership are right on the httptest.cfg file. To start with they might look like…

[root@localhost objects]# ll httptest.cfg -rw-r--r-- 1 root root 0 Aug 11 18:12 httptest.cfg
Change the ownership…

[root@localhost objects]# chown nagios:nagios httptest.cfg [root@localhost objects]# ll httptest.cfg -rw-r--r-- 1 nagios nagios 0 Aug 11 18:12 httptest.cfg
*or use whatever user:group you set up for nagios if they are not that

Change the permissions

[root@localhost objects]# chmod 664 httptest.cfg [root@localhost objects]# ll httptest.cfg -rw-rw-r-- 1 nagios nagios 0 Aug 11 18:12 httptest.cfg
*More *nix… the 664 relates to the three groups of rwx (read, write, execute) permissions on the file. It’s like binary, the r has a value of 4, the w is 2 and the x is 1, so as we want r and w for the first and second set of permissions, thats 4+2=6, and for just the r for the 3rd set, well that’s just 4, so thats what the 664 bit means. When you create your own checks (!) in the future you will need to make them executable like the other checks in the libexec directory, so that’s probably worth knowing :wink:

Happy days. Lastly, modify nagios/etc/nagios.cfg and add

cfg_file=/usr/local/nagios/etc/objects/oncall-group.cfg

Just stick that line in somewhere near the other cfg_file statements.

Lastly use the -v switch to do the ‘pre-flight check’ and make sure everything is in order, and with any luck you’re free of errors and you can restart nagios and be on your way! If you are having errors on the pre-flight check, do post them up and we’ll see what’s what (i.e. fix any stuff I just forgot to mention)

One thing of course, it’s a lifesaver to make a copy of anything you are going to change, just incase it goes south and nagios won’t restart, then backing out your changes is just a matter of copying the original file back - always handy :slight_smile:

HTH

/S

OK this will take a couple of minutes to do but that is no worries. You rock for taking the time to help out like this.

I will let you know how it goes later today when I can sit down and concentrate on your directions and the server.

Lastly any ideas of other sites worth reading to get a better hang of this.

Thanks again.

Bob

Darn I so thought we had it.

I created a new .cfg file and I put in the following code.

define host{
use generic-host ; Inherit default values from a template
host_name webserver ; The name we’re giving to this host
alias Some Web Server ; A longer name associated with the host
address 75.148.115.163 ; IP address of the host
}

define service{
use generic-service ; Inherit default values from a template
host_name webserver
service_description HTTP
check_command check_http!-u applications.beacondatasolutions.com/index.html
}

saved it as websvr.cfg in my …nagios/object dir

I then went to nagios.cfg and added

cfg_file=/usr/local/nagios/etc/objects/websvr.cfg

I checked ownership as a matter of fact I did chown nagios.nagios . in the objects directory.
I also did the same chmod for 6 6 4 like you said.

i went to restart nagios service nagios restart and got

Running configuration check… CONFIG ERROR! Restart aborted. Check your Nagios configuration.

I wanted to see where the config problem is so i resaved websver.cfg blank to see if it was the context of the config file. viola it restarts fine. This leads me to believe that there is something wrong with the context HELP!!!

I doubt this is related but I was also running a copy of PHPlists on this box to send info to customers and suddenly it will not mail. This appears to go along with the install of nagios. Not sure if it makes any changes to my sendmail when we install or what but I can throw it on another box if I need to.

I just tried something else. I shut off all my pointers in nagios.cfg to everything except websvr.cfg. I then copied what I had in windows.cfg into websvr.cfg which ran find. so the issue is certainly in the context of this .cfg file.

Trying everything I can think of I noticed that in the windows config there was a hostgroup defined.

I thought I would add

define host{
use generic-host ; Inherit default values from a template
host_name webserver ; The name we’re giving to this host
alias Some Web Server ; A longer name associated with the host
address 192.168.1.50 ; IP address of the host
}

to the hosts at the top since no hostgroup was defined earlier. No luck here either each and everything I try I get the same error.

CONFIG ERROR! Restart aborted. Check your Nagios configuration.

From what I am doing here it would appear that my nagios.cfg and all the rest of my configs are working correctly except the new websvr.cfg I am trying to get going.

The code looks so simple until I try and implement it and then it is blasting me. grrrrr.

Thanks again for any help anyone can give me.

I will tell you i have learned a lot about nagios today.

I just ran [root@localhost objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

oh i got this with the following .cfg

define host{
use generic-host ; Inherit default values from a template
host_name webserver ; The name we’re giving to this host
alias Some Web Server ; A longer name associated with the host
address 75.148.115.163 ; IP address of the host
}

define service{
use generic-service ; Inherit default values from a template
host_name webserver ;
service_description HTTP ;
check_command check_http!-u applications.beacondatasolutions.com/index.html ;
}

and got the following error.

Copyright © 1999-2008 Ethan Galstad (nagios.org)
Last Modified: 06-25-2008
License: GPL

Reading configuration data…

Error: Invalid max_check_attempts value for host 'webserver’
Error: Could not register host (config file ‘/usr/local/nagios/etc/objects/websvr.cfg’, starting on line 1)

***> One or more problems was encountered while processing the config files…

 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.

I think I finally figured it out and as soon as I get it tested I will post what I found. for anyone that might have this problem in the future.

Hi

Looks like you are having some success and appear to have worked out what might be causing the problem already, but just in case I’ll explain what mistake I made (I knew there would be at least one!)… When I described what the host object should look like I just copied and pasted it out of the earlier web link without paying much thought to it as at first glance it seems reasonable, however on further inspection, the “use generic-host” is what is killing you here. This template (they live in templates.cfg) is essentially missing some of the information required to register the host, because the other ‘default’ templates included, like ‘linux-server’ and ‘windows-server’ inherit this generic-host template and then go on to specify different values for these missing variables. So, what you need to do is use one of these templates, ‘linux-server’ or ‘windows-server’, then nagios will have the full information it needs. Or you could write your own template for values you think appropriate. Or you could add the ‘missing’ values like ‘max_check_attempts 5’ or whatever into the host object itself. Quickest way would be change the ‘use’ line though IMO.

Sorry bout that, was getting late (reckon you must be in the opposite hemisphere to me looking at the times you are posting!) and I guess that’ll teach me to copy’n’paste without checking what was what… does show the documentation up as being wrong though.

Let us know how it goes

/S

New here and just wanted to post a quick thanks to Strides … this thread got me up and running … PLUS I learned a LOT!!

So thanks again Strides!

Strides,

Sorry I did not get back and post a thank you and what I found. I got called out of town on business. You got it nailed that is exactly my problem.

I really do appreciate you working through this with me. I learned a lot on this project making it worth every minute. Hopefully later in the week I will be able to tweak out what I am doing but for now everything is working amazing thanks to you.

Again thank you much for your help and I can not thank you enough for your time.

Bob Not so grumpy thanks to Strides :frowning:

Much obliged fella. Cheers for stopping by and saying thanks as well. All the best.

/S