Nagios Core 4.0.1 installation on Ubuntu 12.04

Raymii

New Member
nagios4.png

This is a guide on installing the latest Nagios Core (4.0.1) on Ubuntu 12.04. Nagios is an open source computer system monitoring, network monitoring and infrastructure monitoring software application. 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. The version in the Ubuntu repositories is quite old, it is still the in the 3 branch. This guide helps to fix that by using the latest Nagios version.

This tutorial was written and testen on a DigitalOcean VPS. If you use this link you get $10 credit free and you sponsor me ass well

You can find more information about Nagios on the official website: http://www.nagios.org/projects/nagioscore.

The description of Nagios Core from their website:


Nagios Core is the monitoring and alerting engine that serves as the primary application around which hundreds of Nagios projects are built. It serves as the basic event scheduler, event processor, and alert manager for elements that are monitored. It features several APIs that are used to extend its capabilities to perform additional tasks, is implemented as a daemon written in C for performance reasons, and is designed to run natively on Linux/*nix systems.


Contents
We are going to do the following:

  • Install required packages
  • Create the Nagios user
  • Download and Compile Nagios Core
  • Download and Compile the Nagios Plugins
  • Download and Compile NRPE
  • Setup the upstart script
  • Set up Apache
Note about currently installed Nagios versions
Make sure you remove all currently installed Nagios versions and packages. Better yet, start on a new empty server/vm.

Note about the plugins and NRPE
We are compiling the latest version of the plugins and NRPE on the Nagios Server. On the Nagios clients, you do not have to do this. The version of NRPE in the Ubuntu repositories works with this newer Nagios version. The same goes for the plugins.

Install required packages
Install the packages required for compilation, apache and mail functionality:


apt-get install apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev libssl-dev sendmail-bin sendmail heirloom-mailx wget curl daemon apt-file libnet-snmp-perl libperl5.14 libpq5 libradius1 libsensors4 libsnmp-base libsnmp15 libtalloc2 libtdb1 libwbclient0 samba-common samba-common-bin smbclient snmp whois libmysqlclient15-dev


Create the Nagios user
Nagios runs as its own user and has its own groups. We need to create this user and groups. We also make sure the user Apache runs as can access the Nagios files by adding the www-data user to the nagios groups.


groupadd -g 3000 nagios
groupadd -g 3001 nagcmd
useradd -u 3000 -g nagios -G nagcmd -d /usr/local/nagios -c 'Nagios Admin' nagios
adduser www-data nagcmd


Download and Compile Nagios Core
If necessary, create /usr/local/src/nagios4:


mkdir -p /usr/local/src/nagios4

cd into /usr/local/src/nagios4:


cd /usr/local/src/nagios4

(I like to keep my source code and compilation files in one place).

Use wget to download the latest Nagios Core from sourceforge:


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

Extract it:


tar xf nagios-4.0.1.tar.gz
cd nagios-4.0.1

Create a few folders:


mkdir -p /usr/local/nagios/share/{stylesheets,images}

Now start the compilation process. First configure:


./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd

Output should look like this:


General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/init.d
Apache conf.d directory: /etc/apache2/conf.d
Mail program: /usr/bin/mail
Host OS: linux-gnu

Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /usr/sbin/traceroute


Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.

Then the make process:


make all

Then the make install, for all the parts:


# This installs the main program, CGIs, and HTML files
make install

# This installs the init script in /etc/init.d
make install-init

# This installs *SAMPLE* config files in /usr/local/nagios/etc
make install-config

#This installs and configures permissions on the directory for holding the external command file
make install-commandmode

# This installs the Apache config file for the Nagios web interface
make install-webconf

# This installs the Exfoliation theme for the Nagios web interface
make install-exfoliation

If this all goes well, we can continue to the next part, which you can find over at https://raymii.org: https://raymii.org/s/tutorials/Nagios_Core_4_Installation_on_Ubuntu_12.04.html
 
Top