Page 1 of 1

Remote linux host not showing in web interface

Posted: Wed Feb 17, 2016 6:17 am
by olivertappin
Hey guys and gals!

I've successfully set up a Nagios Server with the Nagios Core and Nagios Plugins but I'm struggling to see a new host I've added (other than the localhost) in the web interface.

I've trawled the web to find a solution and have tried everything there is but starting to run out of things to try to get this working.

I can access the web interface and view all the pages in the navigation (no authorised access errors showing). I've set up the server with Nginx and PHP-FPM, running on Ubuntu 14.04. I've added the server IP address in the allowed_hosts and only_from configuration files (both on this server and the remote host). It's also worth noting the nrpe service is running via xinetd. And I have used comma separated values for the allowed_hosts and space separated values for only_from.

I can run a nrpe check on the server (when SSHd in) which would suggest the Nagios server is speaking to the client (I've changed the actual IP address to xxx values):

Code: Select all

root@server:/# /usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xxx.xxx
NRPE v2.13

Code: Select all

root@server:/# /usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xxx.xxx -c check_load
OK - load average: 0.60, 0.60, 0.52|load1=0.600;13.000;20.000;0; load5=0.600;13.000;20.000;0; load15=0.520;13.000;20.000;0;
It's worth noting I'm running NRPE v2.15 on the Nagios server and NRPE v2.13 on the Nagios client (the server to be monitored)

I also see the following results when running a configuration check:

Code: Select all

root@server:/# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
	Checked 16 services.
	Checked 2 hosts.
	Checked 1 host groups.
	Checked 0 service groups.
	Checked 1 contacts.
	Checked 1 contact groups.
	Checked 25 commands.
	Checked 5 time periods.
	Checked 0 host escalations.
	Checked 0 service escalations.
Checking for circular paths...
	Checked 2 hosts
	Checked 0 service dependencies
	Checked 0 host dependencies
	Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
As you can see there, it's picking up the second host (where the first is the localhost) in the configuration files, the remote checks work so it seems to be communicating with the server, the only issue is that it's just not showing up in the web interface.

After every configuration change I restart both nrpe and nagios like so:

Code: Select all

sudo service xinetd restart
sudo service nagios restart
And it shows they both restart successfully.

I have also checked the number of processes running (to ensure there aren't two instances of Nagios running):

Code: Select all

root@server:/# ps aux | grep nagios
nagios    4473  0.0  0.1  31720 10912 ?        Ss   10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios -d /etc/nagios/nagios.cfg
nagios    4474  0.0  0.0  10828  2432 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4475  0.0  0.0  10828  2472 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4476  0.0  0.0  10828  2436 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4477  0.0  0.0  10828  2336 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4478  0.0  0.0  10828  2468 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4479  0.0  0.0  10828  2488 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4480  0.0  0.0  10828  2424 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4481  0.0  0.0  10828  2496 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4482  0.0  0.0  10828  2392 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4483  0.0  0.0  10828  2348 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4484  0.0  0.0  10828  2440 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4485  0.0  0.0  10828  2360 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    4486  0.0  0.0  31204  1592 ?        S    10:12   0:00 /usr/local/nagios-4.1.1/bin/nagios -d /etc/nagios/nagios.cfg
root      5382  0.0  0.0  11756  2328 pts/0    S+   11:04   0:00 grep --color=auto nagios
In my /usr/local/nagios/etc/hosts.cfg file, I have the following:

Code: Select all

define host {
    use                     linux-server
    host_name               iguana
    alias                   Iguana
    address                 xxx.xxx.xxx.xxx
}
And in my /usr/local/nagios/etc/services.cfg file I have added the services:

Code: Select all

define service {
    use                     generic-service
    host_name               iguana
    service_description     CPU Load
    check_command           check_nrpe!check_load
}

define service {
    use                     generic-service
    host_name               iguana
    service_description     Total Processes
    check_command           check_nrpe!check_total_procs
}

define service {
    use                     generic-service
    host_name               iguana
    service_description     Current Users
    check_command           check_nrpe!check_users
}

define service {
    use                     generic-service
    host_name               iguana
    service_description     SSH Monitoring
    check_command           check_nrpe!check_ssh
}

define service {
    use                     generic-service
    host_name               iguana
    service_description     FTP Monitoring
    check_command           check_nrpe!check_ftp
}
And I have added both cfg files in my nagios.cfg config like so:

Code: Select all

# 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

# New configuration files added here:
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
Finally, here's a screenshot of my hosts page (showing the localhost but not my external server):

Image

The part I'm confused about is the configuration check shows it's picked up the host and the NRPE check shows the Nagios Sever can indeed speak to the client and return a result. If that's all successful, how come it's not showing up in the web interface? Is there any other checks I can do? There's nothing obvious from what I can see anywhere else and there's nothing in the logs about not being able to communicate with the external server.

Any ideas?

Re: Remote linux host not showing in web interface

Posted: Wed Feb 17, 2016 11:48 am
by rkennedy
Which directory is your actual install directory? Things seemed to be moved around to a lot of different locations.
/usr/local/nagios-4.1.1/
/usr/local/nagios/
/etc/nagios/
Can you post the full result of a ps -ef|grep nagios? I want to make sure you don't have multiple processes running.

Re: Remote linux host not showing in web interface

Posted: Wed Feb 17, 2016 12:03 pm
by olivertappin
To confirm, my install directory is in /usr/local/nagios

Code: Select all

root@server:~# ps -ef | grep nagios
nagios    1914     1  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios -d /etc/nagios/nagios.cfg
nagios    1915  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1916  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1917  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1918  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1919  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1920  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1921  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1922  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1923  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1924  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1925  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1926  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    1927  1914  0 16:05 ?        00:00:00 /usr/local/nagios-4.1.1/bin/nagios -d /etc/nagios/nagios.cfg
root      2387  2373  0 16:56 pts/0    00:00:00 grep --color=auto nagios
I did notice during install things were a bit all over the place. The rc commands are pointing to /usr/local/nagios-4.1.1/bin/nagios and the rest of the installation is pointing to /usr/local/nagios/...

When I saw that, I removed the /usr/local/nagios-4.1.1 directory and created a system link for /usr/local/nagios-4.1.1/ to go to /usr/local/nagios/

This way, everything would come from the same directory (including the configuration files).

I have since changed the prefix in /etc/init.d/nagios and updated the /usr/local/nagios-4.1.1 path to /usr/local/nagios

Where the result now shows this:

Code: Select all

root@server:~# ps -ef | grep nagios
nagios    2899     1  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios -d /etc/nagios/nagios.cfg
nagios    2900  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2901  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2902  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2903  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2904  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2905  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2906  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2907  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2908  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2909  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2910  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2911  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios    2912  2899  0 17:16 ?        00:00:00 /usr/local/nagios/bin/nagios -d /etc/nagios/nagios.cfg
root      2931  2373  0 17:19 pts/0    00:00:00 grep --color=auto nagios
For reference, here's all the matches for nagios:

Code: Select all

root@server:~# find / -name '*nagios*'
/etc/nginx/sites-available/nagios.xxx.xxx.com.conf
/etc/nginx/sites-enabled/nagios.xxx.xxx.com.conf
/etc/rcS.d/S99nagios
/etc/nagios
/etc/nagios/nagios.cfg
/etc/init.d/nagios
/usr/share/locale-langpack/en_GB/LC_MESSAGES/nagios-plugins.mo
/usr/share/locale-langpack/en_AU/LC_MESSAGES/nagios-plugins.mo
/usr/local/nagios-4.1.1
/usr/local/nagios
/usr/local/nagios/etc/nagios.cfg
/usr/local/nagios/bin/nagiostats
/usr/local/nagios/bin/nagios
/usr/local/nagios/share/images/logos/nagios.gd2
/usr/local/nagios/share/images/logos/nagios.gif
/usr/local/nagios/share/images/logos/nagiosvrml.png
/usr/local/nagios/share/images/NagiosEnterprises-whitebg-112x46.png
/usr/local/nagios/share/images/Nagios-clearbg.png
/usr/local/nagios/share/images/action-nagios.gif
/usr/local/nagios/share/locale/de/LC_MESSAGES/nagios-plugins.mo
/usr/local/nagios/share/locale/fr/LC_MESSAGES/nagios-plugins.mo
/usr/local/nagios/share/js/nagios-decorations.js
/usr/local/nagios/share/js/nagios-time.js
/usr/local/nagios/var/nagios.log
/usr/local/nagios/var/nagios.configtest
/usr/local/nagios/var/nagios.lock
/usr/local/nagios/var/rw/nagios.qh
/usr/local/nagios/var/rw/nagios.cmd
/usr/local/nagios/var/archives/nagios-02-12-2016-00.log
/usr/local/nagios/var/archives/nagios-02-15-2016-00.log
/usr/local/nagios/var/archives/nagios-02-14-2016-00.log
/usr/local/nagios/var/archives/nagios-02-16-2016-00.log
/usr/local/nagios/var/archives/nagios-02-13-2016-00.log
/usr/local/nagios/var/archives/nagios-02-17-2016-00.log
/usr/local/nagios/libexec/check_nagios
/var/log/nginx/nagios.xxx.xxx.com-access.log.1
/var/log/nginx/nagios.xxx.xxx.com-access.log
/var/log/nginx/nagios.xxx.xxx.com-error.log.1
/var/log/nginx/nagios.xxx.xxx.com-error.log
/var/log/nagios
/var/log/nagios/nagios.log
/var/www/vhosts/nagios.xxx.xxx.com 
If you think this is a problem, I could try uninstalling Nagios and starting from fresh (obviously trying to avoid that if necessary, if it's just a configuration issue).

Re: Remote linux host not showing in web interface

Posted: Wed Feb 17, 2016 5:23 pm
by tgriep
Run the configuration check with 2 "vv"'s to see if nagios processes that config file. Post the output so we can review it.

Code: Select all

/usr/local/nagios/bin/nagios -vv /usr/local/nagios/etc/nagios.cfg

Re: Remote linux host not showing in web interface

Posted: Wed Feb 17, 2016 5:29 pm
by jolson
If you think this is a problem, I could try uninstalling Nagios and starting from fresh (obviously trying to avoid that if necessary, if it's just a configuration issue).
What I recommend is following this guide exactly if you're running CentOS: https://support.nagios.com/kb/article.p ... ategory=58

It would likely be easier than chasing down the root cause of your issue. It seems like you have a good handle on things, I imagine it wouldn't take you more than an hour to set Nagios Core up from scratch by making use of the above guide.

As a sidenote, if you're using Ubuntu/Debian we also have an installation guide for that: https://support.nagios.com/kb/article.p ... ategory=58

Re: Remote linux host not showing in web interface

Posted: Thu Feb 18, 2016 3:23 am
by olivertappin
Thanks for the help guys.

I ended up removing all instances of Nagios and reinstalling again from source. I would assume an option/configuration setting was incorrect during the initial installation.

All sorted now!

Re: Remote linux host not showing in web interface

Posted: Thu Feb 18, 2016 10:40 am
by rkennedy
Ah! It may have been related to permissions, either way - nice to see you have this resolved!

If you need any help further help now that it's installed, feel free to create a new thread.