Basics - Adding a Host to Nagios Core

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.
workid
Posts: 34
Joined: Wed Oct 10, 2018 7:28 am

Basics - Adding a Host to Nagios Core

Post by workid »

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
Attachments
ncpa.cfg
(1.88 KiB) Downloaded 677 times
cgi.cfg
(13.39 KiB) Downloaded 516 times
nagios.cfg
(44.77 KiB) Downloaded 636 times
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Basics - Adding a Host to Nagios Core

Post by scottwilkerson »

I don't see the ncpa.cfg listed in your nagios.cfg

You should have a line like

Code: Select all

cfg_file=/usr/local/nagios/etc/objects/ncpa.cfg
Then you should run the following from the command line to verify the config and see any errors

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
You can post this output back if you have any questions
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
workid
Posts: 34
Joined: Wed Oct 10, 2018 7:28 am

Re: Basics - Adding a Host to Nagios Core

Post by workid »

scottwilkerson wrote:I don't see the ncpa.cfg listed in your nagios.cfg

You should have a line like

Code: Select all

cfg_file=/usr/local/nagios/etc/objects/ncpa.cfg
Then you should run the following from the command line to verify the config and see any errors

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
You can post this output back if you have any questions
Thanks for the reply

Every time i add a line to nagios.cfg, Nagios fails to start again with the error i posted above, not sure why this happens
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Basics - Adding a Host to Nagios Core

Post by scottwilkerson »

Can you add the line I mentioned and then run the following posting the output

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
workid
Posts: 34
Joined: Wed Oct 10, 2018 7:28 am

Re: Basics - Adding a Host to Nagios Core

Post by workid »

scottwilkerson wrote:Can you add the line I mentioned and then run the following posting the output

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
forget that last post was my own error

the host is now showing up but unreachable - (Return code of 127 is out of bounds. Check if plugin exists)

running that check you mentioned before gives this:

admin-it@GC-NAGIOS:/usr/local/nagios/etc$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/objects/ncpa.cfg

Nagios Core 4.4.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2018-08-16
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Error in configuration file '/usr/local/nagios/etc/objects/ncpa.cfg' - Line 1 (NULL value)
Error processing main config file!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Basics - Adding a Host to Nagios Core

Post by scottwilkerson »

It looks like you are missing the config file

run the following

Code: Select all

ls -al /usr/local/nagios/etc/objects/
Also, if you are getting this you likely do not have the correct path to a plugin in the command definition
Return code of 127 is out of bounds. Check if plugin exists
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
workid
Posts: 34
Joined: Wed Oct 10, 2018 7:28 am

Re: Basics - Adding a Host to Nagios Core

Post by workid »

will this be in command.cfg?

Code: Select all

define command {

    command_name    check_ncpa
    command_line    $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$ 
}

That check command is in command.cfg under the following:
################################################################################
# NOTE: The following 'check_...' commands are used to monitor services on
# both local and remote hosts.
################################################################################

check_ncpa.py is located in /usr/local/nagios/libexec

Does this look correct?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Basics - Adding a Host to Nagios Core

Post by scottwilkerson »

Yes, that looks correct, just like in the "Active Checks (check_ncpa.py)" section of the documentation
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
workid
Posts: 34
Joined: Wed Oct 10, 2018 7:28 am

Re: Basics - Adding a Host to Nagios Core

Post by workid »

ok, well im stuck about the out of bounds error

could it be something to do with when i verify the ncpa.cfg file i get:

admin-it@GC-NAGIOS:/usr/local/nagios/etc$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/objects/ncpa.cfg

Nagios Core 4.4.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2018-08-16
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Error in configuration file '/usr/local/nagios/etc/objects/ncpa.cfg' - Line 1 (NULL value)
Error processing main config file!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Basics - Adding a Host to Nagios Core

Post by scottwilkerson »

First, I asked you to run the following:
It looks like you are missing the config file

run the following

Code: Select all

ls -al /usr/local/nagios/etc/objects/
then, per your previous post you had the following for the configuration

Code: Select all

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
}
There is no check_command defined here, so you would want to see if it is defined in your template you have assigned Windows-Server
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked