Page 1 of 1

nagios configuration errors

Posted: Mon Oct 19, 2015 5:01 pm
by Hikerguy86
Hi

I got nagios installed and used the default files to just add one host just to see what nagios is all about. ok, that worked fine.

I am trying to define templates now so I can dump all of the machines out of AD, write the windows.cfg file with a script and have templated groups that they will all fall into, so I don't have to specify everything for each host manually.

I made a bunch of updates to the templates.cfg file, and some to the contacts.cfg file. However, its the localhost.cfg file that is throwing the errors and I cannot understand why.

Error: Invalid max_check_attempts value for host 'localhost'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 24)
Error processing object config files!

Code: Select all

# Define a host for the local machine

define host{
#        use                     linux-servers            ; Name of host template to use
                                                        ; This host definition will inherit all variables that are defined
                                                        ; in (or inherited by) the linux-server host template definition.
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        }



###############################################################################
###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################
###############################################################################

# Define an optional hostgroup for Linux machines

#define hostgroup{
#        hostgroup_name  linux-servers ; The name of the hostgroup
#        alias           Linux Servers ; Long name of the group
#        members         localhost     ; Comma separated list of hosts that belong to this group
#        }



###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

define service{
        name                                                    local-service           ; The name of this service template
        [b]max_check_attempts              4               [/b]        ; Re-check the service up to 4 times in order to determine its final (hard) state
        normal_check_interval           5                       ; Check the service every 5 minutes under normal conditions
        retry_check_interval            1                       ; Re-check the service every minute until a hard state can be determined
        register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }
Then the particular entries for mem, cpu, disk, etc use the local service definition, or at least they should. for example:

Code: Select all

define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             Swap Usage
        check_command                   check_local_swap!20!10
        }

I have not defined this host or templated service anywhere in the templates.cfg as this is just the localhost and the values i think are what nagios came with in the sample so I can't understand why this is an error. What am I missing?

Re: nagios configuration errors

Posted: Mon Oct 19, 2015 5:50 pm
by Hikerguy86
ok i commented out all of localhost.

Now nagios starts again. But its not picking up all of the check_command lines in template host definition. I'm confused as to how these configurations link together.

an example:

generic-windows-host (this should apply to all hosts defined in windows.cfg based on groups)

Code: Select all

define host{
	name                            generic-windows-host    ; The name of this host template
	notifications_enabled           1       		; Host notifications are enabled
	event_handler_enabled           1       		; Host event handler is enabled
	flap_detection_enabled          1       		; Flap detection is enabled
	process_perf_data               1       		; Process performance data
	retain_status_information       1       		; Retain status information across program restarts
	retain_nonstatus_information    1       		; Retain non-status information across program restarts
	notification_period				24x7			; Send host notifications at any time
	notification_interval			30
	check_period					24x7			; By default, Linux hosts are checked round the clock		
	check_interval					5				; Actively check the host every 5 minutes
	retry_interval					1				; Schedule host check retries at 1 minute intervals
	max_check_attempts				10				; Check each Linux host 10 times (max)		
	check_command					check_nt!USEDDISKSPACE!-l c -w 80 -c 90
	check_command					check_nt!MEMUSE!-w 80 -c 90
	check_command 					check_nt!CPULOAD!-l 5,80,95	
	check_command           		check_nt!CLIENTVERSION
	check_command           		check_nt!UPTIME	
	active_checks_enabled   		1 				; Active host checks are enabled
	passive_checks_enabled  		1 				; Passive host checks are enabled/accepted	
	register                        0       		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
	}

Code: Select all

define host{
	name					windows-Citrix-Servers		; The name of this host template
	use						generic-windows-host	; This template inherits other values from the generic-host template
	check_command           check_nt!SERVICESTATE!-d SHOWALL -l Citrix 64-bit Virtual Memory Optimization
	check_command           check_nt!SERVICESTATE!-d SHOWALL -l Citrix Encryption Service 
	check_command           check_nt!SERVICESTATE!-d SHOWALL -l Citrix EUEM
	check_command           check_nt!SERVICESTATE!-d SHOWALL -l Citrix Virtual Memory Optimization
	check_command           check_nt!SERVICESTATE!-d SHOWALL -l CitrixCseEngine
	check_command           check_nt!SERVICESTATE!-d SHOWALL -l CitrixHealthMon
	check_command           check_nt!SERVICESTATE!-d SHOWALL -l CitrixWMIService
	check_command           check_nt!SERVICESTATE!-d SHOWALL -l CitrixXTEServer
	hostgroups				windows-Citrix-Servers			; Host groups that Windows servers should be a member of
	register				0						; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
	#contact_groups 			support
	}

windows.cfg where host is defined:

Code: Select all

define hostgroup{
        hostgroup_name  windows-Citrix-Servers
        alias           windows-Citrix-Servers
}


define host{
      use             windows-Citrix-Servers                    ; Inherit default values from a template
      host_name       Host1; The name we're giving to this server
      alias           host1  ; A longer name for the server
      address         XXX.XXX.XXX.XXX ; IP address of the server
      active_checks_enabled   1 ; Active host checks are enabled
      passive_checks_enabled  1 ; Passive host checks are enabled/accepted
}
However, on the nagios page the only things that this server is being checked for is ping (up/down) and the CitrixXTEServer service.

How am I supposed to define this properly? Does this not work in a tree/hierarchical manner in which each following host or template inherits all of the objects from the prior and adds to it? Apologies for the newbie questions, Im very new on nagios and I really don't have a wonderful conceptual understanding yet.

Re: nagios configuration errors

Posted: Mon Oct 19, 2015 7:43 pm
by Box293
Hikerguy86 wrote:I made a bunch of updates to the templates.cfg file, and some to the contacts.cfg file. However, its the localhost.cfg file that is throwing the errors and I cannot understand why.

Error: Invalid max_check_attempts value for host 'localhost'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 24)
Error processing object config files!
Hikerguy86 wrote:

Code: Select all

    # Define a host for the local machine

    define host{
    #        use                     linux-servers            ; Name of host template to use
                                                            ; This host definition will inherit all variables that are defined
                                                            ; in (or inherited by) the linux-server host template definition.
            host_name               localhost
            alias                   localhost
            address                 127.0.0.1
            }
The line # use linux-servers has been commented out with the #. "use" means get any directives defined in the template linux-servers. Because it is commented out, the max_check_attempts directive (normally defined in the template) needs to be defined in the host object itself.

https://assets.nagios.com/downloads/nag ... .html#host
Hikerguy86 wrote:Now nagios starts again. But its not picking up all of the check_command lines in template host definition. I'm confused as to how these configurations link together.
From looking at your configs, you're not understanding how object definitions work in Nagios.
You have a host object which has a check command defined to determine if the host is up or down.
Then you have services which are linked to host objects. You can have as many services for a host as you like.
Each service you define will use a check command.
A host object and a service can only have one command defined.

Have a read of this:
https://assets.nagios.com/downloads/nag ... ndows.html
And some more advanced material:
https://assets.nagios.com/downloads/nag ... ricks.html
http://sites.box293.com/nagios/guides/c ... n-services