I'm a Nagios newbie and after reading several doc about hosts, services, commands definitions I came across a pretty dumb error which I can't get pass by.
I followed this tutorial: Official Nagios Tuto
Here is my nagios.cfg code (just a sample, not all the conf):
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timperiodds.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
Now my hosts.cfg:
define host {
host_name nas_01
alias NAS Eth0
address 192.168.1.x ; I did not put 'x' ;)
}
Finally my services.cfg:
define service {
use generic-service ; Inherit default values from a template
host_name nas_01
service_description HTTP
check_command check_http
}
I try to validate the conf file using: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
But I get this error:
Error: Invalid max_check_attempts value for host 'nas_01'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/hosts.cfg', starting on line 7)
If I try to put my host definition in my services.cfg I have the following error:
Warning: Duplicate definition found for host 'nas_01' (config file '/usr/local/nagios/etc/objects/services.cfg', starting on line 7)
Error: Could not add object property in file '/usr/local/nagios/etc/objects/services.cfg' on line 9.
Error: Invalid max_check_attempts value for host 'nas_01'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/hosts.cfg', starting on line 7)
Error processing object config files!
Something seems shady with max_check_attempts
no?
Any ideas?
Alright, so it was nothing...
Basically I forgot to put the 'use linux-server' in my hosts.cfg so it fails because it misses several mandatory attributes such as max_check_attempts
.
hosts.cfg:
define host {
use linux-server
host_name nas_01
alias NAS Eth02
address 192.168.1.16
}
services.cfg:
define service {
use generic-service
host_name nas_01
service_description HTTP Check
check_command check_http
}
Thanks a lot to @Rohlik as he put me on the right way!
Cheers