Basics - Adding a Host to Nagios Core
Posted: Wed Oct 10, 2018 8:32 am
Hi Folks
I'm New to Nagios and linux its self and have been tasked in setting up Nagios Core at work. I have installed Nagios Core following the instructions on the Nagios website, which all went well, can log into the web interface and see localhost.
Now i wanted to test adding a Windows host, so i follow a link on the Nagios instructions to Install NCPA, done this on the Windows PC and added the NCPA.cfg, restarted Nagios and no host shows up, tried a few things but still no luck.
Then wanted to try just basic adding a host in Nagios, following a guide i created a hosts.cfg and defined a host
define host {
use Windows-Server
host_name windows10-thinapp
alias Test
address 172.17.136.147
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
saved it in /usr/local/nagios/etc/objects, i was told i had to add this cfg file into nagios.cfg. So added the line into the file
# OBJECT CONFIGURATION FILE(S)
# These are the object configuration files in which you define hosts,
# host groups, contacts, contact groups, services, etc.
# You can split your object definitions across several config files
# if you wish (as shown below), or keep them all in a single config file.
# You can specify individual object config files as shown below:
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/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
i then stopped Nagios and restarted but it wouldnt restart because of this error:
nagios.service - Nagios Core 4.4.2
Loaded: loaded (/lib/systemd/system/nagios.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-10-10 13:49:05 BST; 41s ago
Docs: https://www.nagios.org/documentation
Process: 12789 ExecStopPost=/bin/rm -f /usr/local/nagios/var/rw/nagios.cmd (code=exited, status=0/SUCCESS)
Process: 12782 ExecStop=/bin/kill -s TERM ${MAINPID} (code=exited, status=0/SUCCESS)
Process: 12688 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Process: 12788 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=1/FAILURE)
Main PID: 12689 (code=exited, status=0/SUCCESS)
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: ***> One or more problems was encountered while processing the config files...
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: Check your configuration file(s) to ensure that they contain valid
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: directives and data definitions. If you are upgrading from a previous
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: version of Nagios, you should be aware that some variables/definitions
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: may have been removed or modified in this version. Make sure to read
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: the HTML documentation regarding the config files, as well as the
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: 'Whats New' section to find out what has changed.
Oct 10 13:49:05 GC-NAGIOS systemd[1]: nagios.service: Control process exited, code=exited status=1
Oct 10 13:49:05 GC-NAGIOS systemd[1]: nagios.service: Failed with result 'exit-code'.
Oct 10 13:49:05 GC-NAGIOS systemd[1]: Failed to start Nagios Core 4.4.2.
So i'm at a complete loss of what im doing at the moment, nothing i do seems to show a host in the web interface, can anyone help and guide me where i am going wrong or tell me the correct procedure to add a host.
I have added the config files, any other info you need just let me know
Thanks
Pete
I'm New to Nagios and linux its self and have been tasked in setting up Nagios Core at work. I have installed Nagios Core following the instructions on the Nagios website, which all went well, can log into the web interface and see localhost.
Now i wanted to test adding a Windows host, so i follow a link on the Nagios instructions to Install NCPA, done this on the Windows PC and added the NCPA.cfg, restarted Nagios and no host shows up, tried a few things but still no luck.
Then wanted to try just basic adding a host in Nagios, following a guide i created a hosts.cfg and defined a host
define host {
use Windows-Server
host_name windows10-thinapp
alias Test
address 172.17.136.147
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
saved it in /usr/local/nagios/etc/objects, i was told i had to add this cfg file into nagios.cfg. So added the line into the file
# OBJECT CONFIGURATION FILE(S)
# These are the object configuration files in which you define hosts,
# host groups, contacts, contact groups, services, etc.
# You can split your object definitions across several config files
# if you wish (as shown below), or keep them all in a single config file.
# You can specify individual object config files as shown below:
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/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
i then stopped Nagios and restarted but it wouldnt restart because of this error:
nagios.service - Nagios Core 4.4.2
Loaded: loaded (/lib/systemd/system/nagios.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-10-10 13:49:05 BST; 41s ago
Docs: https://www.nagios.org/documentation
Process: 12789 ExecStopPost=/bin/rm -f /usr/local/nagios/var/rw/nagios.cmd (code=exited, status=0/SUCCESS)
Process: 12782 ExecStop=/bin/kill -s TERM ${MAINPID} (code=exited, status=0/SUCCESS)
Process: 12688 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Process: 12788 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=1/FAILURE)
Main PID: 12689 (code=exited, status=0/SUCCESS)
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: ***> One or more problems was encountered while processing the config files...
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: Check your configuration file(s) to ensure that they contain valid
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: directives and data definitions. If you are upgrading from a previous
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: version of Nagios, you should be aware that some variables/definitions
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: may have been removed or modified in this version. Make sure to read
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: the HTML documentation regarding the config files, as well as the
Oct 10 13:49:05 GC-NAGIOS nagios[12788]: 'Whats New' section to find out what has changed.
Oct 10 13:49:05 GC-NAGIOS systemd[1]: nagios.service: Control process exited, code=exited status=1
Oct 10 13:49:05 GC-NAGIOS systemd[1]: nagios.service: Failed with result 'exit-code'.
Oct 10 13:49:05 GC-NAGIOS systemd[1]: Failed to start Nagios Core 4.4.2.
So i'm at a complete loss of what im doing at the moment, nothing i do seems to show a host in the web interface, can anyone help and guide me where i am going wrong or tell me the correct procedure to add a host.
I have added the config files, any other info you need just let me know
Thanks
Pete