With the Nagios Looking Glass (NLG) tool, developer Andy Shellam has tried to resolve a common problem for network administrators running Nagios. What happens if you want to provide access to up-to-date information from Nagios without giving users access to the full Nagios console? Providing read-only access to the Nagios console can be complicated, and can occasionally require network re-structuring or can even pose a security risk.
NLG is designed to fix those issues by taking a feed from Nagios status data via an HTTP connection and displaying it on a public Web server. It works in a client-server model with a PHP-based polling server installed on your Nagios server. A receiver client, also PHP-based, is installed on your Web server. If you want to use NLG locally, you can also run the client and the server together on your Nagios server. The receiver client creates an AJAX-enabled page based on a template. You can also customize this template to display whatever you require.
You can see a demo of NLG at http://looking-glass.andyshellam.eu/demo/.
Getting started with NLG
To get NLG up and running, first you need to ensure that you have some pre-requisites on your server and client. On the server side, (on your Nagios server, in other words) you should have:
- Nagios 2.x
- Apache 2
- and PHP 5.
On the client side, you need:
- Apache 2
- the 'dig' command line tool
- PHP 5 (with the allow_url_fopen enabled)
- and, if you want to use HTTPS (which I always recommend), then you need PHP with OpenSSL compiled in.
Next, you need to download the NLG software. The latest version is NLG 1.0.1.
You are required to be root, or su'ed to root, in order to install NLG. Unzip the NLG package:
# unzip nlg_101.zip
Two directories and some documentation files will be created. The server directory needs to be installed onto your Nagios server, and the client directory should be installed on your Web server.
Setting up the NLG server
Here's what you need to do to get started on the server side of your NLG implementation. Copy the server directory in your Nagios share directory, usually /usr/local/nagios/share.
Now, we have to configure the server side. Change into the /usr/local/nagios/share/server/sync-files directory and copy the s3_config.inc.dist file like so:
# cp s3_config.inc.dist s3_config.inc.php
This file is the configuration file for the NLG server. We'll make some edits to this file continue. Specifically, we want to modify the three configuration options you can see below:
$ClientCompanyName = "© Test Company Pty Ltd" $ClientAdminEmailAddress = "firstname.lastname@example.org" $ServerFeed_URL = "http://nagios.testdomain.com/nagios/server/s3_poller.php";
Replace the company name and email address with appropriate values for your environment. Change the server feed URL to the location of the s3_poller.php file on your Nagios server.
If you have enabled authentication on your Nagios server, you will also need to specify a username and password to log into the console with by changing the following options:
$ServerFeed_AuthEnabled = 1; $ServerFeed_AuthUsername = "username"; $ServerFeed_AuthPassword = "password";
Replace the username and password options with appropriate credentials and ensure the authentication enabled option is set to 1. The remaining settings can be left as the defaults.
Setting up the NLG client
Now, we're going to install the client. Move the client directory to an appropriate location on your Web server. For example, make it accessible via the URL: http://webserver.testdomain.com/client/. Change the ownership of the files to the user your Web server is running as,
# chown -R apache:apache /var/www/html/client
Here, we've edited the ownership of the files in the client directory to the apache user and group.
Again, we need to alter a configuration file, this time s3_config_stub.inc.dist. Copy this file and change it so that it has a .php extension like the one below:
# cp s3_config_stub.inc.dist s3_config_stub.inc.php
Edit this file and change the following option to the URL of the Nagios server, the location of the s3_download.php file, which is contained in the server directory we installed on the Nagios server previously:
$Stub_DownloadSource = "http://nagios.testdomain.com/nagios/server/s3_download.php";
The remaining settings are fine as defaults, but you can read through the configuration file to get more details.
Viewing your NLG status information
Finally, you're able to go to the URL, in our case http://webserver.testdomain.com/client/, for the client and display the NLG site. This displays the default site that contains information from your Nagios server. You can customize this view by adjusting the NLG template.
Further details of how to do this are contained in the README file contained in the package and in the NLG manual.You can also find support for NLG at http://www.andyshellam.eu/ase_v62/projects/software/looking-glass/support.phpx.
This was first published in February 2007