Page 2 of 3

Re: Defining new nagios service

Posted: Mon Jul 07, 2014 2:21 pm
by i386
eloyd wrote:
...However, that does not explain why it works when I comment out the new definitions.
If you're commenting out a line that has a non-printable character in it, then that does explain it. :-)

Oh, sorry, I should have been clear. I comment out the new definition, which is at the bottom. when I try and restart the deamon it complains about line 1. which is far from the bottom.

Re: Defining new nagios service

Posted: Mon Jul 07, 2014 2:22 pm
by eloyd
For fun, try this:

Code: Select all

strings clientone.cfg > clientone_new.cfg
mv clientone.cfg clientone.cfg.sav
mv clientone_new.cfg clientone.cfg 
See if it passes the sanity check

Re: Defining new nagios service

Posted: Mon Jul 07, 2014 2:26 pm
by i386
eloyd wrote:For fun, try this:

Code: Select all

strings clientone.cfg > clientone_new.cfg
mv clientone.cfg clientone.cfg.sav
mv clientone_new.cfg clientone.cfg 
See if it passes the sanity check
no go.

Code: Select all

[root@nagios1 servers]# strings clientone.cfg > clientone_new.cfg
[root@nagios1 servers]# mv clientone.cfg clientone.cfg.sav
[root@nagios1 servers]# mv clientone_new.cfg clientone.cfg 
[root@nagios1 servers]# ls -la
total 16
drwxr-xr-x. 2 nagios nagios 4096 Jul  7 14:24 .
drwxrwxr-x. 6 nagios nagios 4096 Jul  5 17:47 ..
-rw-r--r--. 1 root   root   1243 Jul  7 14:24 clientone.cfg
-rw-r--r--. 1 nagios nagios 1254 Jul  7 14:13 clientone.cfg.sav
-rw-r--r--. 1 root   root      0 Jul  7 14:24 One
-rw-r--r--. 1 root   root      0 Jul  7 14:24 The

[root@nagios1 servers]# service nagios restart
Running configuration check... CONFIG ERROR!  Restart aborted.  Check your Nagios configuration.
[root@nagios1 servers]# 

Re: Defining new nagios service

Posted: Mon Jul 07, 2014 2:27 pm
by i386
eloyd wrote:
I have the following, but I want to be sure its correct:
Nope. You can't have a "command_line" in a service check.
  • The service check definition uses "check_command" to specify the command and arguments.
    "check_command" is defined in commands.cfg
    The commands.cfg has a list of what FILE to execute when the COMMAND is given, and passes the ARGUMENTS to it.
You will want to look at http://nagios.sourceforge.net/docs/3_0/ ... ml#service for details.

I shall have a look.

Re: Defining new nagios service

Posted: Mon Jul 07, 2014 2:29 pm
by eloyd
Please post as an attachment your entire clientone.cfg file. Click on "upload attachment" below the "Save | Preview | Submit" buttons.

Re: Defining new nagios service

Posted: Tue Jul 08, 2014 12:20 am
by i386
eloyd wrote:Please post as an attachment your entire clientone.cfg file. Click on "upload attachment" below the "Save | Preview | Submit" buttons.

Please find the file attached.

Re: Defining new nagios service

Posted: Tue Jul 08, 2014 6:41 am
by eloyd
Lots of problems in this file:
  • You have no closing "}" for the first definition.
  • You have no closing "}" for the second definition.
  • You use "command_name" in the last definition - should be "check_command"
  • In the same one, "check_disk!/" is not a valid check_command. I assume it should be "check_local_disk" if it's the machine that's running Nagios, or else you'll need to use an NRPE command here.
Fixing these got it to parse properly on my server.

Re: Defining new nagios service

Posted: Tue Jul 08, 2014 9:18 am
by i386
eloyd wrote:Lots of problems in this file:
  • You have no closing "}" for the first definition.
  • You have no closing "}" for the second definition.
  • You use "command_name" in the last definition - should be "check_command"
  • In the same one, "check_disk!/" is not a valid check_command. I assume it should be "check_local_disk" if it's the machine that's running Nagios, or else you'll need to use an NRPE command here.
Fixing these got it to parse properly on my server.

Hi

The missing brackets } are do to some commands that i ran earlier from this forum.

I think we may be one to something with the nrpe commands. by chance do you know the nrpe command for checking disk?
I tried finding it but I have not had any luck.

Re: Defining new nagios service

Posted: Tue Jul 08, 2014 9:24 am
by eloyd
To get NRPE working to check disks on a remote host, you need to edit "/usr/local/nagios/etc/nrpe/common.cfg" to make sure that this line is in there somewhere:

Code: Select all

command[check_disk]=/usr/local/nagios/libexec/check_disk $ARG1$
Then on your Nagios host, edit /usr/local/nagios/etc/commands.cfg (or wherever it lives) to make sure you have a check_nrpe command:

Code: Select all

define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a "$ARG2$"
}
Then you can make a service check that uses check_nrpe command on the Nagios host to use NRPE to execute the check_disk command on the remote host with the appropriate parameters:

Code: Select all

define service{
        use                     nrpe-service
        service_description     Root Partition
        hostgroups              private
        servicegroups           System
        check_command           check_nrpe!check_disk!-w 20% -c 10% -p /
}
(Note that we use hostgroups to specify what services should be checked on each machine. Use an appropriate "host_name XXX" command for your configuration.)

Does that help?

Re: Defining new nagios service

Posted: Tue Jul 15, 2014 9:26 am
by tmcdonald
i386, did eloyd's post help you at all?