Tip

Nagios setup: Installing and configuring the network monitoring tool

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

    Requires Free Membership to View

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.

Installing Nagios
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):

nagios
nagios-plugins
nagios-plugins-extras
nagios-www

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.

Configuring Nagios
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" >

# SSLRequireSSL

Options None

AllowOverride None

Order allow,deny

Allow from all

# Order deny,allow

# Deny from all

# Allow from 127.0.0.1

AuthName "Nagios Access"

AuthType Basic

AuthUserFile /etc/nagios/htpasswd.users

Require valid-user

< /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.

This was first published in September 2010

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.