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

Defining new nagios service

Post by i386 »

Hello All

I am new to Nagios. I recently installed it. I currently have the nagios host running. It is monitoring one client server using the Nagios Remote Plugin Executor (nrpe).
I hope that someone can help me, as assistance would be greatly appreciated.

I am trying to define a new service to monitor the root hard disk.

I currently have the following.

Code: Select all

define service {
        use                             generic-service
        host_name                  nagc1
        service_description      disk
        command_name          check_disk
        command_line            /usr/lib64/nagios/plugins/check_disk -v / -c 5 -w 7
        }
 
for some reason this does not seem to be working. I cant seem to understand why. This service definition is a copy of another service definition which is working fine.
when I try and restart the nagios service I get the following error:

Code: Select all

[root@nagios1 servers]# service nagios start
Starting nagios:CONFIG ERROR!  Start aborted.  Check your Nagios configuration.
I have also tried to run a sanity check.

Code: Select all

[root@nagios1 servers]# nagios -v clientone.cfg

Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Error in configuration file '/etc/nagios/servers/clientone.cfg' - Line 1 (NULL value)
   Error processing main config file!



***> The name of the main configuration file looks suspicious...

     Make sure you are specifying the name of the MAIN configuration file on
     the command line and not the name of another configuration file.  The
     main configuration file is typically '/usr/local/nagios/etc/nagios.cfg'

***> 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.
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 »

Error in configuration file '/etc/nagios/servers/clientone.cfg' - Line 1 (NULL value)
This is your problem. You may have a character in this file in line one that doesn't display on your screen that is causing the Nagios processor to not be able to read the file properly. Try deleting line one and see what happens (assuming line one is empty).
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 »

This is often seen when copying a file from a Windows environment. Can you post the /etc/nagios/servers/clientone.cfg file please?
Former Nagios employee
i386
Posts: 13
Joined: Mon Jul 07, 2014 11:35 am

Re: Defining new nagios service

Post by i386 »

eloyd wrote:
Error in configuration file '/etc/nagios/servers/clientone.cfg' - Line 1 (NULL value)
This is your problem. You may have a character in this file in line one that doesn't display on your screen that is causing the Nagios processor to not be able to read the file properly. Try deleting line one and see what happens (assuming line one is empty).

Hi

First off Thank you for your help!!!!

I would like to believe that is the problem. However the configuration file is fine if I comment out the new service definition.
besides, I did go down that road, but was not able to see this 'character' thats being complained about.

Code: Select all

[root@nagios1 servers]# cat -n clientone.cfg
     1	define host {
     2	        use                     linux-server
     3	        host_name               nagc1
     4	        alias                   nagc1
     5	        address                 192.168.1.107
     6	#        hostgroups              allhosts
     7		}
     8	
     9	define service {
    10	        use                             generic-service
    11	        host_name                       nagc1
    12	        service_description             PING
    13	        check_command                   check_ping!100.0,20%!500.0,60%
    14	        normal_check_interval 10
    15	        retry_check_interval  1
    16		}
    17	
    18	define service {
    19	        use                             generic-service
    20	        host_name                       nagc1
    21	        service_description             SSH
    22	        check_command                   check_ssh
    23	        notifications_enabled           0
    24	        }
    25	
    26	define service {
    27	        use                             generic-service
    28	        host_name                       nagc1
    29	        service_description             Current Load
    30	        check_command                   check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
    31	        }
    32	
    33	define service {
    34	        use                             generic-service
    35	        host_name                       nagc1
    36	        service_description             disk 
    37	        command_name                    check_disk
    38	#        command_line                    /usr/lib64/nagios/plugins/check_disk -v / -c 5 -w 7
    39	        }
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 »

Does Trevor's comment shed any light?
This is often seen when copying a file from a Windows environment
If it were me, I'd delete lines 1-8 and recreate them by manually typing the information back in.
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 »

tmcdonald wrote:This is often seen when copying a file from a Windows environment. Can you post the /etc/nagios/servers/clientone.cfg file please?

Code: Select all

[root@nagios1 servers]# cat -n clientone.cfg
     1	define host {
     2	        use                     linux-server
     3	        host_name               nagc1
     4	        alias                   nagc1
     5	        address                 192.168.1.107
     6	#        hostgroups              allhosts
     7		}
     8	
     9	define service {
    10	        use                             generic-service
    11	        host_name                       nagc1
    12	        service_description             PING
    13	        check_command                   check_ping!100.0,20%!500.0,60%
    14	        normal_check_interval 10
    15	        retry_check_interval  1
    16		}
    17	
    18	define service {
    19	        use                             generic-service
    20	        host_name                       nagc1
    21	        service_description             SSH
    22	        check_command                   check_ssh
    23	        notifications_enabled           0
    24	        }
    25	
    26	define service {
    27	        use                             generic-service
    28	        host_name                       nagc1
    29	        service_description             Current Load
    30	        check_command                   check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
    31	        }
    32	
    33	define service {
    34	        use                             generic-service
    35	        host_name                       nagc1
    36	        service_description             disk 
    37	        command_name                    check_disk
    38	#        command_line                    /usr/lib64/nagios/plugins/check_disk -v / -c 5 -w 7
    39	        }
i386
Posts: 13
Joined: Mon Jul 07, 2014 11:35 am

Re: Defining new nagios service

Post by i386 »

eloyd wrote:Does Trevor's comment shed any light?
This is often seen when copying a file from a Windows environment
If it were me, I'd delete lines 1-8 and recreate them by manually typing the information back in.

You know? I did copy the original code from a web site. Then I modified it with my server details.
I will delete lines 1 - 8, and type them in manually.

...However, that does not explain why it works when I comment out the new definitions.

let me ask another question.

can some one post the service definitions akd "define service" for the root(/) hard disk check on a nrpe client?

I have the following, but I want to be sure its correct:

Code: Select all

33	define service {
    34	        use                             generic-service
    35	        host_name                       nagc1
    36	        service_description             disk 
    37	        command_name                    check_disk
    38	        command_line                    /usr/lib64/nagios/plugins/check_disk -v / -c 5 -w 7
    39	        }
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 »

...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. :-)
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
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 »

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.
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 »

i386 wrote:
eloyd wrote:Does Trevor's comment shed any light?
This is often seen when copying a file from a Windows environment
If it were me, I'd delete lines 1-8 and recreate them by manually typing the information back in.

You know? I did copy the original code from a web site. Then I modified it with my server details.
I will delete lines 1 - 8, and type them in manually.

...However, that does not explain why it works when I comment out the new definitions.

let me ask another question.

can some one post the service definitions akd "define service" for the root(/) hard disk check on a nrpe client?

I have the following, but I want to be sure its correct:

Code: Select all

33	define service {
    34	        use                             generic-service
    35	        host_name                       nagc1
    36	        service_description             disk 
    37	        command_name                    check_disk
    38	        command_line                    /usr/lib64/nagios/plugins/check_disk -v / -c 5 -w 7
    39	        }

Okay, Ive deleted lines 1-8 and manaually entered them. Now its complaining about line 2. Go figure.

Code: Select all

[root@nagios1 servers]# nagios -v clientone.cfg

Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Error in configuration file '/etc/nagios/servers/clientone.cfg' - Line 2 (NULL value)
   Error processing main config file!



***> The name of the main configuration file looks suspicious...

     Make sure you are specifying the name of the MAIN configuration file on
     the command line and not the name of another configuration file.  The
     main configuration file is typically '/usr/local/nagios/etc/nagios.cfg'

***> 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.

[root@nagios1 servers]# cat -n clientone.cfg
     1	
     2	define host {
     3		use				linux-server
     4		host_name			nagc1
     5		alias				nagc1
     6		address				192.168.1.107
     7		}
     8	
Locked