Basics - Adding a Host to Nagios Core

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Basics - Adding a Host to Nagios Core

Postby workid » 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
Attachments
ncpa.cfg
(1.88 KiB) Downloaded 29 times
cgi.cfg
(13.39 KiB) Downloaded 24 times
nagios.cfg
(44.77 KiB) Downloaded 29 times
workid
 
Posts: 26
Joined: Wed Oct 10, 2018 7:28 am

Re: Basics - Adding a Host to Nagios Core

Postby scottwilkerson » Wed Oct 10, 2018 8:39 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12594
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Basics - Adding a Host to Nagios Core

Postby workid » Wed Oct 10, 2018 8:48 am

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

Re: Basics - Adding a Host to Nagios Core

Postby scottwilkerson » Wed Oct 10, 2018 8:57 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12594
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Basics - Adding a Host to Nagios Core

Postby workid » Wed Oct 10, 2018 9:01 am

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

Re: Basics - Adding a Host to Nagios Core

Postby scottwilkerson » Wed Oct 10, 2018 9:23 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12594
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Basics - Adding a Host to Nagios Core

Postby workid » Wed Oct 10, 2018 9:37 am

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

Re: Basics - Adding a Host to Nagios Core

Postby scottwilkerson » Wed Oct 10, 2018 9:39 am

Yes, that looks correct, just like in the "Active Checks (check_ncpa.py)" section of the documentation
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12594
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Basics - Adding a Host to Nagios Core

Postby workid » Wed Oct 10, 2018 9:57 am

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

Re: Basics - Adding a Host to Nagios Core

Postby scottwilkerson » Wed Oct 10, 2018 10:04 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12594
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Next

Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot] and 13 guests