Difference between revisions of "How to Setup and configure Nagios"

From CDOT Wiki
Jump to: navigation, search
(2.0 Server Installation)
Line 79: Line 79:
 
<code>useradd -m nagios</code>
 
<code>useradd -m nagios</code>
 
    
 
    
<code>passwd senecaCdot</code>
+
<code>passwd **********</code>
  
 
2. Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.
 
2. Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

Revision as of 08:46, 19 November 2010

Version 0.2


1.0 About Nagios

Nagios is a system and network monitoring application. It watches hosts and services that you specify, and provides critical notifications to administrators, when the system/network performance is being negatively impacted.

Nagios was originally designed to run under Linux, but it possessess the capability of being compatible with a host of other OSs as well.

Some of the many features of Nagios include:

  • Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
  • Monitoring of host resources (processor load, disk usage, etc.)
  • Simple plug-in design that allows users to easily develop their own service checks
  • Parallelized service checks
  • Ability to define network host hierarchy using "parent" hosts, 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 user-defined method)
  • Ability to define event handlers to be run during service or host events for proactive problem resolution
  • Automatic log file rotation
  • Support for implementing redundant monitoring hosts
  • Optional web interface for viewing current network status, notification and problem history, log file, etc.


2.0 Server Installation

This guide will provide you with instructions on how to install Nagios from source (code) on Fedora 13 and have it monitoring your local and client machines.

2.1 Features available after instalation

  • Nagios and the all plugins will be installed underneath /usr/local/nagios
  • Nagios will be configured to monitor a few aspects of your local system (CPU load, disk usage, etc.)
  • Monitor Nagios clients


2.2 Prerequisites

During portions of the installation you will need to have root access to your machine.

Note: root password is **********

Make sure you've installed the following packages on your Fedora 13 installation before continuing.

  • Apache
  • PHP
  • GCC compiler
  • GD development libraries
Note: you have to be root to install the following packages.

yum install httpd php

yum install gcc glibc glibc-common

yum install gd gd-devel


2.3 Create Account Information

1. While you still have root privilages from a previous step, create a new nagios user account and give it a password.

useradd -m nagios

passwd **********

2. Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

groupadd nagcmd

usermod -a -G nagcmd nagios

usermod -a -G nagcmd apache


2.4 Download Nagios and the Plugins

1. Create a directory for storing the downloads.

mkdir ~/nagios/downloads

cd ~/nagios/downloads

Download the source code tarballs of both Nagios and the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions).

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz

wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz


2.5 Compile and Install Nagios

1. Extract the Nagios source code tarball.

cd ~/nagios/downloads

tar xzf nagios-3.2.3.tar.gz

cd nagios-3.2.3

2. Run the Nagios configure script, passing the name of the group you created earlier, using the following command:

./configure --with-command-group=nagcmd

3. Compile the Nagios source code.

make all

4. Install binaries, init script, sample config files and set permissions on the external command directory.

Note: you have to be root to issue the following commands.

make install

make install-init

make install-config

make install-commandmode

Note: DO NOT start Nagios yet


2.6 Customize Configuration

Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts.

vi /usr/local/nagios/etc/objects/contacts.cfg

Note: this will be changed to Chris Tyler’s email.


2.7 Configure the Web Interface

1. Install the Nagios web config file in the Apache conf.d directory.

cd /home/nagios/downloads/nagios-3.2.3

Note: you have to be root to issue the following command. 

make install-webconf

2. Create a nagiosadmin account for logging into the Nagios web interface.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Type the password: **********

3. Restart Apache to make the new settings take effect. service httpd restart


2.8 Compile and Install the Nagios Plugins

1. Extract the Nagios plugins source code tarball.

cd ~/downloads

tar xzf nagios-plugins-1.4.15.tar.gz

cd nagios-plugins-1.4.15

2. Compile and install the plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios

make

Note: you have to be root to issue make install command.

make install


2.9 Start Nagios

1. Add Nagios to the list of system services and have it automatically start when the system boots.

chkconfig --add nagios

chkconfig nagios on

2. Verify the sample Nagios configuration files.

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

You have to have no warnings or errors:

Total Warnings: 0
Total Errors: 0

3. If there are no errors, start Nagios. If you got errors, please check nagios.cfg file in step 2, and try it again. service nagios start


2.10 Modify SELinux Settings

Fedora ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs.

1. See if SELinux is in Enforcing mode.

getenforce

2. Put SELinux into Permissive mode.

setenforce 0

3. To make this change permanent, you'll have to modify the settings in /etc/selinux/config and reboot. Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode:

chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/

chcon -R -t httpd_sys_content_t /usr/local/nagios/share/


2.11 Login to the Web Interface

You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier. For a password that you configured please refere to the section 2.7, step 2.

http://localhost/nagios/

Click on the "Service Detail" navigational bar link to see details of what's being monitored on your local machine. It will take a few minutes for Nagios to check all the services associated with your machine, as the checks are spread out over time.


2.12 Open Port 5666 on Firewall

Make sure your machine's firewall rules are configured to allow access to the web server if you want to access the Nagios interface remotely.

1. Create a rule for iptables.

iptables -I INPUT -p tcp -m tcp ---dport 5666 -j ACCEPT

2. Save the new iptables rule so it will survive machine reboots.

service iptables save


2.13 You're Done

Congratulations! You sucessfully installed Nagios. Your journey into monitoring is just beginning. You have just completed the basic configuration of the Nagios Server. You'll no doubt want to monitor more than just your local machine, so keep reading and you will find how to configure the client machine with some modifications on Nagios server. If you did everything as per specifications, the following page will be displayed upon initial access of the Nagios Server GUI: