Defining new nagios service

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.
i386
Posts: 13
Joined: Mon Jul 07, 2014 11:35 am

Re: Defining new nagios service

Post 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.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Defining new nagios service

Post 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
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
i386
Posts: 13
Joined: Mon Jul 07, 2014 11:35 am

Re: Defining new nagios service

Post 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]# 
i386
Posts: 13
Joined: Mon Jul 07, 2014 11:35 am

Re: Defining new nagios service

Post 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.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Defining new nagios service

Post by eloyd »

Please post as an attachment your entire clientone.cfg file. Click on "upload attachment" below the "Save | Preview | Submit" buttons.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
i386
Posts: 13
Joined: Mon Jul 07, 2014 11:35 am

Re: Defining new nagios service

Post 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.
Attachments
clientone.cfg
(1.22 KiB) Downloaded 259 times
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Defining new nagios service

Post 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.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
i386
Posts: 13
Joined: Mon Jul 07, 2014 11:35 am

Re: Defining new nagios service

Post 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.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Defining new nagios service

Post 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?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Defining new nagios service

Post by tmcdonald »

i386, did eloyd's post help you at all?
Former Nagios employee
Locked