Install Nagios Core 4.1.1 in Debian Jessie Part 3

Now that we have our Nagios working, we might need some other clients to work with. We already have Check_MK for some checks,but in this guide we are going to install a couple more clients.

SNMP MIBs

In some cases, mostly with routers, we need to use SNMP for checks and the OID are differents than Linux or Windows OS.

Installing MIBs

For licensing reasons, net-snmp package installs only a small number of MIBs in /usr/share/mibs directory. A large number of standard MIBs can be installed using snmp-mibs-downloader package:

apt-get install snmp-mibs-downloader
download-mibs

To add another MIBs than default, for example cisco MIBs:

cp /usr/share/doc/snmp-mibs-downloader/examples/cisco* /etc/snmp-mibs-downloader/
cd /etc/snmp-mibs-downloader && sudo gzip -d ciscolist.gz

Change /etc/snmp-mibs-downloader/snmp-mibs-downloader.conf to

BASEDIR=/var/lib/mibs
AUTOLOAD="rfc ianarfc iana cisco"

Change /etc/snmp-mibs-downloader/cisco.conf to

HOST=ftp://ftp.cisco.com
ARCHIVE=v2.tar.gz
ARCHTYPE=tgz
DIR=pub/mibs/v2/
ARCHDIR=auto/mibs/v2
CONF=ciscolist
DEST=cisco

Edit /etc/snmp-mibs-downloader/ciscolist and remove lines containing

CISCO-802-TAP-MIB
CISCO-IP-TAP-CAPABILITY
CISCO-IP-TAP-MIB
CISCO-SYS-INFO-LOG-MIB
CISCO-TAP2-CAPABILITY
CISCO-TAP2-MIB
CISCO-TAP-MIB
CISCO-USER-CONNECTION-TAP-MIB

Start downloading all the configured MIBs

download-mibs

Oracle Instant Client

This tutorial explains how to set-up the check_oracle_health script (credits to Gerhard Lausser) to work on your Nagios environment on CentOS (or any RedHat based Linux). This nagios plugin allows to monitor many oracle DB parameters – like tablespaces size, session, process count, SGA pool etc. Check it out on the author’s webset.
The hardest part of the setup is installing the dependent perl libraries and making modifications in the perl code for them to work.
On oracle server we need to create the monitoring user and grant rights, only the minimum necessary for the script to work.

su – oracle
sqlplus / as sysdba

Type the commands:

CREATE USER nagios IDENTIFIED BY account unlock;
GRANT CREATE SESSION TO nagios;
GRANT SELECT any dictionary TO nagios;
GRANT SELECT ON V_$SYSSTAT TO nagios;
GRANT SELECT ON V_$INSTANCE TO nagios;
GRANT SELECT ON V_$LOG TO nagios;
GRANT SELECT ON SYS.DBA_DATA_FILES TO nagios;
GRANT SELECT ON SYS.DBA_FREE_SPACE TO nagios;

Dependencies

apt-get install libaio-dev libaio1 alien

Installing Oracle Check Health

On Nagios server:

cd /usr/src
wget https://labs.consol.de/assets/downloads/nagios/check_oracle_health-2.1.3.1.tar.gz
tar xvzf check_oracle_health-2.1.3.1.tar.gz 
cd check_oracle_health-2.1.3.1
./configure
make
make install

Note: For more info, please check the official documentation

Install oracle instant client

We have to download this files:

oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
cd /usr/src 
alien --scripts *.rpm
dpkg -i *.deb
mkdir /usr/lib/oracle/12.1/client64/network/admin -p
export PATH=$PATH:$HOME/bin:/usr/lib/oracle/12.1/client64/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/12.1/client64/lib
export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export TNS_ADMIN=$ORACLE_HOME/network/admin

Installing perl libraries for Oracle DBD

perl -MCPAN -e 'get DBD::Oracle'
cd /root/.cpan/build/DBD-Oracle*
perl Makefile.PL -l
make
make install

 

VMWare ESXi and vSphere Client

The plugin can monitor either a single ESXi/vSphere server or a VirtualCenter/vCenter Server and individual virtual machines. We’ll see here how to monitor an ESXi host.

Prerequisites

apt-get install libxml2-dev libssl-dev libxml-libxml-perl e2fsprogs perl-doc libuuid-perl libnagios-plugin-perl

One particular perl module ask for the Apache sources, so we have to download it and set the directory before start the installation process.

cd /usr/src
apt-get source apache2
APACHE_SRC=/usr/src/apache2-2.4.10/

Installation

Installing VMWare vSphere Command Line Interface on Debian we may have a problem. It reports missing packages and RPM errors. Basically the script looks for a file /etc/*-release and uses this to determine what type of system it is installing on. Since Debian does not have this file it falls back to assuming a RedHat based system and uses RPM to check for required dependencies. Not suprisingly this fails.

The quickest way to get round this is to pretend the system is ubuntu and install, then delete the ubuntu file:

echo ubuntu > /etc/temp-release

The prerequisite for the plugin to work is to install the VMWare Perl SDK available on the manufacturer website.
Download the file on your server, for example in /usr/src directory, untar it and run the installer that way :

cd /usr/src
tar xvzf VMware-vSphere-Perl-SDK-6.0.0-2503617.x86_64.tar.gz
cd vmware-vsphere-cli-distrib/
./vmware-install.pl

Follow the instructions given by the script. Depending on your setup, some PERL dependencies must be installed prior for the SDK to work correctly.

We are going to change only the default directory:

In which directory do you want to install the executable files? 
[/usr/bin] /usr/local/nagios/libexec/vmware_cli

When it’s done, we can get the plugin here, and copy it to /usr/local/nagios/libexec/vmware_cli. Make it executable :

cd /usr/local/nagios/libexec/vmware_cli
wget https://raw.githubusercontent.com/lplinux/scripts/master/check_vmware_api.pl
chmod a+x check_vmware_api.pl
./check_vmware_api.pl -V
check_vmware_api.pl 0.7.1

Configuration

Now, we can start the real configuration for Nagios. We’ll need a username and password to access the ESXi host, let’s define those Nagios variables in a safe place in /usr/local/nagios/etc/resource.cfg, so that this information will be hidden from the CGIs :

$USER9$=USER
$USER10$=PASSWORD

In this tutorial, we’ll be monitoring these resources : CPU, memory usage, net usage, runtime status and IO/read/write. But some more are available, see the references here. Below are the new commands related to ESXi to add in the /usr/local/nagios/etc/objects/commands.cfg file (these are the ESXi related commands only, NOT the full commands.cfg, you may append this at the end of the file) :

define command {
        command_name    check_vmware_RUNTIME
        command_line    $USER1$/vmware_cli/check_vmware_api.pl -H $HOSTADDRESS$ -u $USER9$ -p $USER10$ -l runtime -s status
}

define command {
        command_name    check_vmware_CPU
        command_line    $USER1$/vmware_cli/check_vmware_api.pl -H $HOSTADDRESS$ -u $USER9$ -p $USER10$ -l cpu -s usage -w $ARG1$ -c $ARG2$
}

define command {
        command_name    check_vmware_MEM
        command_line    $USER1$/vmware_cli/check_vmware_api.pl -H $HOSTADDRESS$ -u $USER9$ -p $USER10$ -l mem -s usage -w $ARG1$ -c $ARG2$
}

define command {
        command_name    check_vmware_DATASTORE
        command_line    $USER1$/vmware_cli/check_vmware_api.pl -H $HOSTADDRESS$ -u $USER9$ -p $USER10$ -l vmfs -s $ARG1$ -o used -w "$ARG2$" -c "$ARG3$"
}

define command {
        command_name    check_vmware_IOREAD
        command_line    $USER1$/vmware_cli/check_vmware_api.pl -H $HOSTADDRESS$ -u $USER9$ -p $USER10$ -l io -s read -w $ARG1$ -c $ARG2$
}

define command {
        command_name    check_vmware_IOWRITE
        command_line    $USER1$/vmware_cli/check_vmware_api.pl -H $HOSTADDRESS$ -u $USER9$ -p $USER10$ -l io -s write -w $ARG1$ -c $ARG2$
}

define command {
        command_name    check_vmware_NET
        command_line    $USER1$/vmware_cli/check_vmware_api.pl -H $HOSTADDRESS$ -u $USER9$ -p $USER10$ -l net -s usage -w $ARG1$ -c $ARG2$
}

And this is an example of HOST and SERVICES:

# Host esx01
define host{
        use                     linux-server
        host_name               esxi01
        alias                   VMWare ESXi 01
        address                 10.50.40.121
        }
 
# Define a service to "ping" the local machine
define service{
        use                             generic-service
        host_name                       esxi01
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }
 
# VMWare check cpu
define service{
        use                             generic-service
        host_name                       esxi01
        service_description             ESXi CPU Load
        check_command                   check_esx_cpu!80!90
        }
 
# check memory usage
define service{
        use                             generic-service
        host_name                       esxi01
        service_description             ESXi Memory usage
        check_command                   check_esx_mem!80!90
        }
 
# check net
define service{
        use                             generic-service
        host_name                       esxi01
        service_description             ESXi Network usage
        check_command                   check_esx_net!102400!204800
        }
 
# check runtime status
define service{
        use                             generic-service
        host_name                       esxi01
        service_description             ESXi Runtime status
        check_command                   check_esx_runtime
        }
 
# check io read
define service{
        use                             generic-service
        host_name                       esxi01
        service_description             ESXi IO read
        check_command                   check_esx_ioread!40!90
        }
 
# check io write
define service{
        use                             generic-service
        host_name                       esxi01
        service_description             ESXi IO write
        check_command                   check_esx_iowrite!40!90
        }

Reference Links:

Print Friendly, PDF & Email

Pablo Javier Furnari

Linux System Administrator at La Plata Linux
I'm a Linux Sysadmin with 8 years of experience. I work with several clients as a consulter here in Argentina and oversea (I have clients in the United States, Mexico, Pakistan and Germany).

I know my strengths and weaknesses. I'm a quick learner, I know how to work with small and big teams. I'm hard worker, proactive and I achieve everything I propose.

One thought on “Install Nagios Core 4.1.1 in Debian Jessie Part 3

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image