Unable to verify nagios.cfg


#1

Hi folks, I just started setting up my Nagios to monitor my Windows server. I have modified my windows.cfg and setup NSClient++ to run in the windows server. However when trying to verify my nagios.cfg I am getting this unusual error:

monitor@nagios:/etc/nagios3$ sudo nagios3 -v nagios.cfg
Nagios 3.0.2
Copyright © 1999-2008 Ethan Galstad (nagios.org)
Last Modified: 05-19-2008
License: GPL
Reading configuration data…
Error: Invalid max_check_attempts value for host ‘serverdc’
Error: Could not register host (config file ‘/etc/nagios3/windows.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.


Here’s my windows.cfg code:
define host{ windows-server ; Inherit default values from a Windows server template (make sure you keep this line!)
host_name serverdc
alias serverdc
address 172.16.220.45
}
define service {
use generic-service
host_name serverdc
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
define service{
use generic-service
host_name serverdc
service_description Uptime
check_command check_nt!UPTIME
}
define service{
use generic-service
host_name serverdc
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
define service{
use generic-service
host_name serverdc
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}

define service{
use generic-service
host_name serverdc
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
use generic-service
host_name serverdc
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}
define service{
use generic-service
host_name serverdc
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}


Can anyone please tell me on what’s wrong and what needs to be done?
Much Appreciated.
db :roll:


#2

Here’s your problem…

[quote]Here’s my windows.cfg code:
define host{** windows-server** ; Inherit default values from a Windows server template (make sure you keep this line!)
host_name serverdc
alias serverdc
address 172.16.220.45
}[/quote]

Try

[quote]Here’s my windows.cfg code:
define host{
use windows-server ; Inherit default values from a Windows server template (make sure you keep this line!)
host_name serverdc
alias serverdc
address 172.16.220.45
}[/quote]

HTH

/S


#3

Thanks for the reply, Strides.
I did your recommendation but now came up with this error:
Error: Template ‘windows-server’ specified in host definition could not be not found (config file ‘/etc/nagios3/windows.cfg’, starting on line 1)
Any ideas?


#4

erk. windows-server is usually defined by default in the sample configs in templates.cfg. It should look something like this…

[quote]define host{
name windows-server ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, Windows servers are monitored round the clock
check_interval 5 ; Actively check the server every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 3 ; Check each server 10 times (max)
check_command check-host-alive ; Default command to check if servers are "alive"
notification_period 24x7 ; Send notification out at any time - day or night
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
hostgroups windows-servers ; Host groups that Windows servers should be a member of
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}[/quote]

If it isn’t in templates.cfg or templates.cfg isn’t being loaded for some reason, make sure you have this template somewhere else in one of your loaded cfg files, for instance you could just paste it in at the top of windows.cfg or something. If you don’t know what cfg files are being loaded, check your cfg_file (or cfg_dir) variables in your nagios.cfg file.

HTH

/S


#5

I copied and pasted the below script you posted on top of my windows.cfg file, is this what I’m supposed to do?
Anyway I’ve done it and ran verify and came up with this new error:
Reading configuration data…
Error: Invalid host object directive ‘windows-server’.
Error: Could not add object property in file ‘/etc/nagios3/windows.cfg’ on line 17.
Also found my conf.d directory under /etc/nagios3 which has the following files:
contacts_nagios2.cfg
host_groups.cfg
services_nagios2.cfg

Any of these files I need to configure ?
Please advise.

[quote=“Strides”]erk. windows-server is usually defined by default in the sample configs in templates.cfg. It should look something like this…

[quote]define host{
name windows-server ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, Windows servers are monitored round the clock
check_interval 5 ; Actively check the server every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 3 ; Check each server 10 times (max)
check_command check-host-alive ; Default command to check if servers are "alive"
notification_period 24x7 ; Send notification out at any time - day or night
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
hostgroups windows-servers ; Host groups that Windows servers should be a member of
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}[/quote]

If it isn’t in templates.cfg or templates.cfg isn’t being loaded for some reason, make sure you have this template somewhere else in one of your loaded cfg files, for instance you could just paste it in at the top of windows.cfg or something. If you don’t know what cfg files are being loaded, check your cfg_file (or cfg_dir) variables in your nagios.cfg file.

HTH

/S[/quote]