Installing Nagios on Ubuntu

Installing Nagios on Ubuntu

Prerequisites

To follow this tutorial, you must have superuser privileges on the Ubuntu 14.04 server that will run Nagios. Ideally, you will be using a non-root user with superuser privileges. If you need help setting that up, follow the steps 1 through 3 in this tutorial: Initial Server Setup with Ubuntu 14.04.

A LAMP stack is also required. Follow this tutorial if you need to set that up: How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 14.04.

This tutorial assumes that your server has private networking enabled. If it doesn't, just replace all the references to private IP addresses with public IP addresses.

Now that we have the prerequisites sorted out, let's move on to getting Nagios 4 installed.

==========================================================================
Paul's method:

http://sharadchhetri.com/2013/06/11/how-to-install-and-configure-nagios-nrpe-client-in-ubuntu-with-apt-get-command/

422  apt-get update
  423  apt-get install openssl nagios-nrpe-server nagios-plugins nagios-plugins-basic nagios-plugins-standard
  424  cp -p  /etc/nagios/nrpe.cfg /etc/nagios/nrpe.cfg.orig
  425  /etc/nagios/nrpe.cfg
  426  vi /etc/nagios/nrpe.cfg
  427  /etc/init.d/nagios-nrpe-server restart
  428  vi /etc/snmp/snmpd.conf  <-- make sure 67.22.128.170 is added under allowed hosts.
  429  mkdir -p /usr/local/nagios/libexec && cd /usr/local/nagios/ && wget http://67.22.128.199/file/nagios-libexec-v0.2.tar.gz && tar -zxvf nagios-libexec-v0.2.tar.gz
  430  cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak`date +%m%d%Y`
  431  cd /usr/local/nagios/libexec && rm -f /etc/snmp/snmpd.conf && mv snmpd.conf /etc/snmp/
  432  vi /etc/snmp/snmpd.conf 
  433  service snmpd restart
==========================================================================

Install Nagios 4

This section will cover how to install Nagios 4 on your monitoring server. You only need to complete this section once.

Create Nagios User and Group

We must create a user and group that will run the Nagios process. Create a "nagios" user and "nagcmd" group, then add the user to the group with these commands:

 
  • sudo useradd nagios
  • sudo groupadd nagcmd
  • sudo usermod -a -G nagcmd nagios

Install Build Dependencies

Because we are building Nagios Core from source, we must install a few development libraries that will allow us to complete the build. While we're at it, we will also install apache2-utils, which will be used to set up the Nagios web interface.

First, update your apt-get package lists:

 
  • sudo apt-get update

Then install the required packages:

 
  • sudo apt-get install build-essential libgd2-xpm-dev openssl libssl-dev xinetd apache2-utils unzip

Let's install Nagios now.

Install Nagios Core

Download the source code for the latest stable release of Nagios Core. Go to the Nagios downloads page, and click the Skip to download link below the form. Copy the link address for the latest stable release so you can download it to your Nagios server.

At the time of this writing, the latest stable release is Nagios 4.1.1. Download it to your home directory with curl:

cd ~
curl -L -O https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz

Extract the Nagios archive with this command:

 
  • tar xvf nagios-*.tar.gz

Then change to the extracted directory:

 
  • cd nagios-*

Before building Nagios, we must configure it. If you want to configure it to use postfix (which you can install with apt-get), add --with-mail=/usr/sbin/sendmail to the following command:

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

Now compile Nagios with this command:

 
  • make all

Now we can run these make commands to install Nagios, init scripts, and sample configuration files:

 
  • sudo make install
  • sudo make install-commandmode
  • sudo make install-init
  • sudo make install-config
  • sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf

In order to issue external commands via the web interface to Nagios, we must add the web server user, www-data, to the nagcmd group:

 
  • sudo usermod -G nagcmd www-data

Install Nagios Plugins

Find the latest release of Nagios Plugins here: Nagios Plugins Download. Copy the link address for the latest version, and copy the link address so you can download it to your Nagios server.

At the time of this writing, the latest version is Nagios Plugins 2.1.1. Download it to your home directory with curl:

cd ~
curl -L -O http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz

Extract Nagios Plugins archive with this command:

 
  • tar xvf nagios-plugins-*.tar.gz

Then change to the extracted directory:

 
  • cd nagios-plugins-*

Before building Nagios Plugins, we must configure it. Use this command:

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

Now compile Nagios Plugins with this command:

 
  • make

Then install it with this command:

 
  • sudo make install

Install NRPE

Find the source code for the latest stable release of NRPE at the NRPE downloads page. Download the latest version to your Nagios server.

At the time of this writing, the latest release is 2.15. Download it to your home directory with curl:

 
  • cd ~
  • curl -L -O http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

Extract the NRPE archive with this command:

 
  • tar xvf nrpe-*.tar.gz

Then change to the extracted directory:

 
  • cd nrpe-*

Configure NRPE with these commands:

 
  • ./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu

Now build and install NRPE and its xinetd startup script with these commands:

 
  • make all
  • sudo make install
  • sudo make install-xinetd
  • sudo make install-daemon-config

Open the xinetd startup script in an editor:

 
  • sudo vi /etc/xinetd.d/nrpe

Modify the only_from line by adding the private IP address of the your Nagios server to the end (substitute in the actual IP address of your server):

only_from = 127.0.0.1 10.132.224.168

Save and exit. Only the Nagios server will be allowed to communicate with NRPE.

Restart the xinetd service to start NRPE:

 
  • sudo service xinetd restart

Now we can add to our nagios web interface here: http://nagios.hspheredns.com/admin/host/new
 
    • Related Articles

    • Installing WHM/Cpanel

      To install CPanel first make sure perl is installed and updated yum -y install perl Then update the hostname to it's proper hostname, you can find it here: nano /etc/sysconfig/network Navigate to root user's home cd /home Then download the latest ...
    • Auto-installing Windows Servers PsExec

      The Bacula4 Windows auto-installer works on PsExec functionality. https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx Using this functionality, Bacula4 will auto-install and configure your Windows Servers and Virtual Machines with the ...
    • Installing Bacula4Hosts Hsphere Control Panel Module

      To install Hsphere package su - cpanel java psoft.hsp.tools.PkgInstaller --package=Bacula1.0.2.hsp (replace 1.0.2.hsp with current version - ie x.x.x.hsp) Once installed, log into hsphere admin CP and navigate to E.Manager > 3rd Party Tools > ...
    • How to Migrate Email Between Hosting Companies/Domains

      Disclaimer/Notice: The below is for advanced users and is provided only as a courtesy - Cartika Hosting Support cannot assist with the operation/setup of this script beyond providing basic mail settings. All support inquiries need to go to the ...
    • enable cURL on WHM/cPanel using EasyApache

      How to enable cURL on WHM/cPanel using EasyApache Authorsupport support Article Reference NumberAA-05017 Views10659 How to enable cURL on WHM/cPanel using EasyApache Overview A command line tool for getting or sending files using URL syntax. To ...