Pages

Tuesday, June 26, 2012

Nagios-Installation

Nagios is an open source host, service and network monitoring program. It is designed to run under Linux, although it should work under most other *NIX variants. It can run either as a normal process or as a daemon, intermittently running checks on various services that you specify. The actual service checks are performed by external "plug-in" which return service information to Nagios. Several CGI programs are included with Nagios in order to allow you to view the current service status, history, etc. via a web browser.

Nagios has a lot of features, making it a very powerful monitoring tool. Some of the major features are listed below:
•   Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
•   Monitoring of host resources (processor load, disk and memory usage, running processes, log files, etc.)
•   Monitoring of environmental factors such as temperature
•   Simple plugin design that allows users to easily develop their own host and service checks
•   Ability to define network host hierarchy, allowing detection of and distinction between hosts that are down and those that are unreachable
•   Contact notifications when service or host problems occur and get resolved (via email, pager, or other user-defined method)
•   Optional escalation of host and service notifications to different contact groups
•   Ability to define event handlers to be run during service or host events for proactive problem resolution
•   Support for implementing redundant and distributed monitoring servers
•   External command interface that allows on-the-fly modifications to be made to the monitoring and notification behavior through the use of event handlers, the web interface, and third-party applications
•   Retention of host and service status across program restarts
•   Scheduled downtime for suppressing host and service notifications during periods of planned outages
•   Ability to acknowledge problems via the web interface
•   Web interface for viewing current network status, notification and problem history, log file, etc.
•   Simple authorization scheme that allows you restrict what users can see and do from the web interface

License

Nagios is licensed under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation. This gives you legal permission to copy, distribute and/or modify Nagios under certain conditions. Read the 'LICENSE' file in the Nagios distribution or read the online version of the license for more details. Nagios is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.

Support

Linux

Website

http://www.nagios.org/about/screenshots.php

 Installing Nagios

* Important: Installing and configuring Nagios is rather involved. You can't just compile the binaries, run the program and sit back. There's a lot to setup before you can actually start monitoring anything. Relax, take your time and read all the documentation - you're going to need it. Okay, let's get started...

Become Root:

You'll need to have root access to install Nagios as described in this documentation, as you'll be creating users and group, modifying your web server config files, etc. Either login as root before you begin or use the su command to change to the root user from another account.

Getting The Latest Version

You can download the latest version of Nagios from http://www.nagios.org/ download.

Unpacking The Distribution

To unpack the Nagios distribution, use the following command:

#tar xzf nagios-version.tar.gz

When you have finished executing these commands, you should find a nagios-version directory that has been created in your current directory. Inside that directory you will find all the files that comprise the core Nagios distribution.

Create Nagios User/Group

You're probably going to want to run Nagios under a normal user account, so add a new user (and group) to your system with the following command (this will vary depending on what OS you're running):

#adduser nagios

Create Installation Directory


Create the base directory where you would like to install Nagios as follows...

#mkdir /usr/local/nagios

Change the owner of the base installtion directory to be the Nagios user and group you added earlier as follows:

#chown nagios.nagios /usr/local/nagios

Identify Web Server User

You're probably going to want to issue external commands (like acknowledgements and scheduled downtime) from the web interface. To do so, you need to identify the user your web server runs as (typically apache, although this may differ on your system). This setting is found in your web server configuration file. The following command can be used to quickly determine what user Apache is running as (paths may differ on your system):

#grep "^User" /etc/httpd/conf/httpd.conf

Add Command File Group

Next we're going to create a new group whose members include the user your web server is running as and the user Nagios is running as. Let's say we call this new group 'nagcmd' (you can name it differently if you wish). On RedHat Linux you can use the following command to add a new group (other systems may differ):

#/usr/sbin/groupadd nagcmd

Next, add the users that your web server and Nagios run as to the newly created group with the following commands (I'll assume apache and nagios are the respective users):

#/usr/sbin/usermod -G nagcmd apache
#/usr/sbin/usermod -G nagcmd nagios


Run the Configure Script


Run the configure script to initialize variables and create a Makefile as follows...(the last two options: --with-command-xxx are optional, but needed if you want to issue external commands)

#./configure --prefix=prefix --with-cgiurl=cgiurl --with-htmurl=htmurl --with-nagios-user=someuser --with-nagios-group=somegroup --with-command-group=cmdgroup

    * Replace prefix with the installation directory that you created in the step above (default is /usr/local/nagios)
    * Replace cgiurl with the actual url you will be using to access the CGIs (default is /nagios/cgi-bin). Do NOT append a slash at the end of the url.
    * Replace htmurl with the actual url you will be using to access the HTML for the main interface and documentation (default is /nagios/)
    * Replace someuser with the name of a user on your system that will be used for setting permissions on the installed files (default is nagios)
    * Replace somegroup with the name of a group on your system that will be used for setting permissions on the installed files (default is nagios)
    * Replace cmdgroup with the name of the group running the web server (default is nagios, in the example above it was nagcmd). This will allow group members (i.e. your web server) to be able to submit external commands to Nagios.


Compile Binaries

Compile Nagios and the CGIs with the following command:

#make all

Installing The Binaries And HTML Files


Install the binaries and HTML files (documentation and main web page) with the following command:

#make install


Installing An Init Script

If you wish, you can also install the sample init script to /etc/rc.d/init.d/nagios with the following command:

#make install-init

You may have to edit the init script to make sense with your particular OS and Nagios installation by editing paths, etc.

Directory Structure And File Locations

Change to the root of your Nagios installation directory with the following command...

#cd /usr/local/nagios

You should see five different subdirectories. A brief description of what each directory contains is given in the table below.

Sub-Directory:    Contents
bin/:            Nagios core program
etc/:    Main, resource, object, and CGI configuration files should be put here
sbin/:    CGIs
share/:    HTML files (for web interface and online documentation)
var/:            Empty directory for the log file, status file, retention file, etc.
var/archives/:  Empty directory for the archived logs
var/rw:    Empty directory for the external command file

Installing The Plugins

In order for Nagios to be of any use to you, you're going to have to download and install some plugins. Plugins are usually installed in the libexec/ directory of your Nagios installation (i.e. /usr/local/nagios/libexec). Plugins are scripts or binaries which perform all the service and host checks that constitute monitoring. You can grab the latest release of the plugins from the Nagios downloads page or directly from the SourceForge project page.

Setup The Web Interface

You're probably going to want to use the web interface, so you'll also have to read the instructions on setting up the web interface and configuring web authentication, etc. next.

Configuring Nagios

So now you have things compiled and installed, but you still haven't configured Nagios or defined objects (hosts, services, etc.) that should be monitored.


Adding web authentication for users in nagios

/usr/local/apache/bin/htpasswd /usr/local/nagios/etc/htpasswd.users guest

No comments:

Post a Comment