Tuesday, 13 August 2013

Install Nagios in ubuntu 13.04 32bit from source

Nagios core is an opensource system to monitor many things in network. Nagios offers monitoring and alerting services for servers, switches, applications, and services. It alerts the users when things go wrong and alerts them a second time when the problem has been resolved.
Because it free, opensource and easy to custom, many companies have applied it to monitor your system.
Today, I will present how to install nagios in ubuntu 13.04 32bit.

This article used information in Quickstart Installation Guides in nagios documents

Preconfigure
Must change regional format to English or will having errors in some plugin like check_mk:

regional format blogspot tientuts

Some package in my countries Ubuntu repo  don't support some packages like openssh-service. Please use main repo.
Change with command line, use: https://help.ubuntu.com/community/Locale

Setup
Go to superuser mode
sudo -s

Install dependencies
apt-get update
apt-get install build-essential apache2 php5-gd wget libgd2-xpm libgd2-xpm-dev libapache2-mod-php5 libssl-dev libapache2-mod-python -y

Create Account Information
/usr/sbin/useradd -m -s /bin/bash nagios
passwd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd www-data

Download and extract files

mkdir ~/downloads
cd ~/downloads
wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
tar -xzvf nagios-3.5.0.tar.gz
tar -zxvf nagios-plugins-1.4.16.tar.gz

Compile and Install Nagios
cd nagios/
./configure --with-command-group=nagcmd --enable-event-broker
make all
make install
make install-init
make install-config
make install-commandmode

Configure the Web Interface
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/etc/init.d/apache2 reload

Compile and Install Nagios plugin
cd ~/downloads
cd nagios-plugins-1.4.16/
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make


Error and fix (Important)

when make with new linux distro like ubuntu 13.04 or centos 6.4 (don't appear in ubuntu 12.04), I met this error, view image:

go to gl folder of nagios-plugin , go to stdio.h file (must make to get this file), search gets.
And you will see the line like this:
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
change gets to fgets.

Continue compile and Install Nagios plugin
cd ~/downloads/nagios-plugins-1.4.16/
make
make install

Start Nagios and set startup

ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start

Login to the Web Interface

http://localhost/nagios/
or http://127.0.0.1/nagios/

username: nagiosadmin

Install ssh server
sudo apt-get install openssh-server
to ssh from other pc

Install more plugins
apt-get install nagios-plugins*

folder of plugins:
/usr/local/nagios/libexec (from source)
/usr/lib/nagios/plugins (from apt-get)

No comments:

Post a Comment