Server management tools shed light on data center issues
A comprehensive collection of articles, videos and more, hand-picked by our editors
This is the initial installation in a series of tips on using the open source network monitoring tool Nagios. Part...
two of the series covers how to use Nagios for remote server monitoring, while part three details using Nagios plugins. In this part first of our series, you’ll learn about Nagios installation and configuration.
Nagios is a versatile open source network monitoring tool. Because it is plug-in-oriented, it can be used to monitor a broad variety of operating systems and devices on the network, and if no specific plug-in is available, it can always fall back on the Simple Network Management Protocol (SNMP) standard, which makes Nagios an extremely versatile monitoring tool. In this article, you'll learn how to setup a Nagios system in your environment.
In a basic configuration, you'll set up one Nagios host that monitors the nodes in the same network. That means that there is no firewall blocking traffic between the Nagios host and the nodes that it monitors. In larger networks, you might want to configure multiple Nagios hosts, where the on-site Nagios servers monitor local traffic and communicate with a centralized Nagios server that makes sure the monitoring data is available at one location in the network.
In many cases where large sites are involved, it is a good idea to run Nagios in a distributed setup. Every Nagios server is responsible for gathering and processing its own data. Also, the individual server will take care that alerts are sent out if necessary. By doing this work on the local servers, you can offload performance issues from the centralized Nagios server but still benefit from the fact that this server offers one point of access to which you can connect the Nagios Web interface. In this article, however, I'll cover a standalone installation of Nagios only. Nagios runs on all of the major Linux distributions, and here I'll use OpenSUSE 11.2 as the example. You'll find that the procedure described is more or less similar on your favorite distribution.
You don't need a huge server to install Nagios. For monitoring of up to 100 nodes, the system requirements are so low that any server will do. Only if you're planning to monitor thousands of nodes on one server does it become important to have multiple CPU cores in your server as well as 2 GB of RAM and about 40 GB of available disk space.
There are two options to install Nagios: from the repositories provided by your favorite Linux distribution or from the source files that you'll find on the Nagios website. In an enterprise environment, supported Linux distributions such as Red Hat Enterprise Linux and SUSE Linux Enterprise Server are commonly used, and in such environments for support reasons it is a much better idea to install Nagios from the repositories. For SUSE Linux, that means you can use YaST or the command line utility zypper (the SUSE equivalent to Red Hat's yum and Ubuntu's apt-get) to install the required packages. Make sure that the following packages are installed (note that on Red Hat there is no nagios-www package):
To do this with zypper, you can use the following command:
zypper install nagios nagios-plugins nagios-plugins-extras nagios-www
After installing these packages, the Nagios service is installed on your server as well as an alias for the Apache Web server. To start using Nagios, you have to make sure that the Apache Web server is (re)started and the Nagios service is started:
service apache2 restart
service nagios start
To do its work, Nagios has also installed a user with the name nagios and a group nagios. These user accounts are not that important for your daily work, but they are needed by the Nagios daemon, which uses them to run the Nagios service and access files on the file system. The Nagios configuration itself is stored in different files. First, there are the configuration files that are written to /etc/nagios. In here, you'll find important files, such as commands.conf, which contains the basic commands that Nagios uses to do its work. Even more important are the plug-ins that you find in /usr/lib/nagios/plugins. These plug-ins are scripts that are developed to monitor specific services -- the plug-ins really are what makes Nagios such a versatile service. Plug-ins can be developed for anything and a good set of them is provided by default. Apart from these default plug-ins, you can also write your own. In a follow-up on this article, you'll find more details about these plug-ins.
After installing it, you need to create a basic Nagios configuration. The most important part is already installed: the nagios.conf file that is used with the Apache Web server and makes sure that Nagios can be reached on the /nagios Apache alias on your server.
Partial content of the Apache configuration file for Nagios:
Alias /nagios "/usr/share/nagios"
< Directory "/usr/share/nagios" >
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
< /Directory >
In this file, basic authentication is enabled for Nagios. This is not the most secure method of handling authentication, but it will do for the moment. The authentication works with the /etc/nagios/htpasswd.users file, which should contain the names of all users that are allowed access to the Nagios administration interface. The following command shows how to add a user nagiosadmin to this file:
htpasswd2 -c /etc/nagios/htpasswd.users nagiosadmin
Enter the password for the nagiosadmin user twice and you'll have a user account that you can use to access the Nagios management interface. At this point you can restart the Apache server to make sure that all recent changes are active, open a browser and enter http://localhost/nagios. This should bring you to the Web interface that you see in the figure below. From this interface, you can start exploring the options Nagios has to offer. In the next part of this article, you'll learn how to work with it and how to add other nodes for Nagios monitoring.