Showing posts with label Nagios. Show all posts
Showing posts with label Nagios. Show all posts

Sunday, 17 March 2013

Integrating Nagvis to Nagios

Integrating Nagvis front-end to Nagios 

If you want to make your Nagios look really professional, want to customise the it to make it look absolutely customer presentable. Nagvis is the tool for you.

Installing NagVis Front End for Nagios. This tool will allow you creating a cool visual for your Nagios portal. You can create a nice diagram with Visio and use it to make your Nagios portal look more professionally presentable to customers.

If you have followed my previous post on how to Install Nagios (Centos 6) easy way, all you have to do is to follow the steps below, and you will have both (Nagios and Nagvis) working and nicely integrated.

There are few packages we must install first:

Dependencies:
* rsync
* graphviz
* php-mbstring
* php
* php-gd 
* php-pdo
* mk-livestatus-1.1.12.rhel6.x86_64.rpm

Installing required Packages

# yum install rsync graphviz php-mbstring php-gd php-pdo php -y 

Downloading mk-live
# cd /usr/local/
# mkdir downloads
# cd downloads
# wget http://www.thruk.org/files/pkg/v1.52/rhel6/x86_64/mk-livestatus-1.1.12.rhel6.x86_64.rpm
# rpm -Uvh mk-livestatus-1.1.12.rhel6.x86_64.rpm

or

Simply issue the command below:
# rpm -Uvh http://www.thruk.org/files/pkg/v1.52/rhel6/x86_64/mk-livestatus-1.1.12.rhel6.x86_64.rpm

Once the mk-live package has been installed, we need to move to configuring the it, by integrating it to the Nagios.
Note: If you followed my previous post about installing Nagios, your Nagios config files should be on /etc/nagios

Configure mk-live package
# cd /etc/nagios
# mkdir -p var/rw
# chown -R nagios: var/

Edit Nagios.cfg file
# vi /etc/nagios/nagios.cfg

Add the lines bellow to the nagios.cfg and save it
broker_module=-1
broker_module=/usr/lib64/mk-livestatus/livestatus.o /etc/nagios/var/rw/live

 Restart Nagios and Apache
# service nagios restart
# service httpd restart

Note: I would like to draw your attention to something very important.
A good systems Administrator always make sure he/she has a backup of any modified file.
Before you change configuration files, it is good practice to make a copy of the file you are about to change.

Downloading and Installing NagVis Package
# cd /usr/local/downloads
# wget http://sourceforge.net/projects/nagvis/files/NagVis%201.7/nagvis-1.7.2.tar.gz/download
# tar -zxvf nagvis-1.7.2.tar.gz
# cd nagvis-1.7.2
# ls 
Note: you should see various files including a README and a INSTALL.
The installation process is described in the INSTALL file, I suggest taking a look at it..

Once the package has been decompressed and expanded, we need to install it.

Installing Nagvis
# chmod 755 install.sh
# ./install.sh
The install.sh script will check various things within your system, including; path to Nagios, path to mk-live and all the required packages if they are installed.

Questions asked by install.sh script

1. Do you want to proceed? [y]: Y
   hit [ENTER]

2. Please enter the path to the nagios base directory [/usr/sbin/nagios]: /etc/nagios
   hit [ENTER]

3. Please enter the path to NagVis base [/usr/sbin/nagvis]: /etc/nagvis
   hit [ENTER]

4. Script will check for all required packages, see below:
|   PHP 5.3                                                              found |
|   PHP Module: gd php                                                   found |
|   PHP Module: mbstring php                                             found |
|   PHP Module: gettext compiled_in                                      found |
|   PHP Module: session compiled_in                                      found |
|   PHP Module: xml compiled_in                                          found |
|   PHP Module: pdo php                                                  found |
|   Apache mod_php                                                       found |

Note: If any package is presented as missing, kill the script and install the missing package.

5. Do you want to use backend mklivestatus? [y]:Y
   hit [ENTER]

6. Do you want to use backend ndo2db? [n]:n
   hit [ENTER]

7. Do you want to use backend ido2db? [n]:n
   hit [ENTER]

8. Do you want to use backend merlinmy? [n]:n
   hit [ENTER]

9. Livestatus Socket (/etc/nagios/var/rw/live)                             found |
|   PHP Module: sockets compiled_in                                        found |
|   Graphviz 2.26                                                          found |
|   Graphviz Module dot 2.26.0                                             found |
|   Graphviz Module neato 2.26.0                                           found |
|   Graphviz Module twopi 2.26.0                                           found |
|   Graphviz Module circo 2.26.0                                           found |
|   Graphviz Module fdp 2.26.0                                             found |
|   SQLite 3.6                                                             found |

Note: Make sure everything on the list above has been found.
Otherwise kill the script and install the missing packages.

10.  Please enter the web path to NagVis [/nagvis]:
     hit [ENTER]

11. Please enter the name of the web-server user [apache]:
     hit [ENTER]

    Please enter the name of the web-server group [apache]:
     hit [ENTER]

    create Apache config file [y]:
     hit [ENTER]

12. Do you want the installer to update your config files when possible? [y] y
    hit [ENTER]

13. Remove backup directory after successful installation? [n]: n
    hit [ENTER]

Note: At this time Nagvis will display a summary of all choices made by you, if everything looks OK as I describe above,

just accept it.
 14.  Do you really want to continue? [y]: y
     hit [ENTER]

Once the installation has been complete, restart Apache
# service httpd restart

Accessing Nagvis frontend
Open your bowser and point it to: http://192.168.1.23/nagvis

User Name: admin
Password: Admin

By this point you should see the default Nagvis frontend and there are various demo you can see.

It is pretty easy to install the localhost to be monitored.
I will create a how to with screenshots at later date.

Make sure NagVis has enabled the LIVE backend

# cd /etc/nagvis/etc
# vi nagvis.ini.php

Search for the line: 
; backend="live_1"

Remove the ';' (semi-colonm) and save the file
backend="live_1"

Save the file and restart Apache and Nagios

# service httpd restart
# service nagios restart

Now you should be able to add easily the localhost and any servers you might already have configured.


I hope you enjoy these How To I am creating. I am trying to make them as detailed as possible and not escape or miss steps.


Troubleshooting
# tail /var/log/message 
Note: any error message generated by Nagios will be logged to this file.

My next how to will be on how to make this useful and I will post my work online.
I intend to create a Visio diagram including all the racks at the Data Centre, with all servers positioned correctly and just save it as a Jpeg and use it as my NagVis MAP.

by Renato de Oliveira





Saturday, 16 March 2013

Nagios (Centos 6) Easy way

Nagios (Centos 6) Easy way

I decided to write this post because I am currently implementing a massive Nagios installation.
Which includes two Data Centres and two offices.
My next post will be on how to configure a server to be monitored by Nagios.

Centos 6 Easier way to install Nagios Server

Install Epel Repository GPG key
# rpm --import http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6

Install Epel Repository Package
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

Search and Install Nagios Packages
Required Packages:
nagios.x86_64
nagios-plugins.x86_64
nagios-plugins-all.x86_64
httpd.x86_64

Install the packages
# yum install httpd.x86_64 nagios.x86_64 nagios-plugins.x86_64 nagios-plugins-all.x86_64 -y
Note: on my brand new system I had 78 packages installed.
It might be different on your system, depends on how many packages you already have installed.

Configuring Apache
# chkconfig --level 35 httpd on
# service httpd start

Test Apache Install
Open your broser and navigate to your server IP address to test Apache works
If it doesn't we need to open up the firewall

# vi /etc/sysconfig/iptables

Add the line below:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Save the file and restart iptables
# service iptables restart

Test acessing your Nagios IP address once again
http://192.168.1.23
Note: If you see the Apache Test Page your Apache is working fine
Replace 192.168.1.23 with your server's IP address

Setup Nagios Apache Virtual Host
# cd /etc/httpd/conf.d/
# vi nagios.conf

The file should look as per below:

ScriptAlias /nagios/cgi-bin/ "/usr/lib64/nagios/cgi-bin/"

<Directory "/usr/lib64/nagios/cgi-bin/">
#  SSLRequireSSL
   Options ExecCGI
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /etc/nagios/passwd
   Require valid-user
</Directory>

Alias /nagios "/usr/share/nagios/html"

<Directory "/usr/share/nagios/html">
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /etc/nagios/passwd
   Require valid-user
</Directory>

Restart Apache
# service httpd restart

Set an User Name and Password to protect Nagios access
# htpasswd -c /etc/nagios/passwd nagiosadmin
New password: TYPE in a Password
Re-type new password: Type the same password again

Test the Nagios web Interface access
http://192.168.1.23/nagios/
Type in: nagiosadmin and your password

Note: If you see the Nagios Web Interface, things are looking good and Nagios is installed correctly.

We need to start Nagios service
# chkconfig --level 35 nagios on

Start Nagios
# service nagios start

Navigate to the Nagios web Interface at: http://192.168.1.23/nagios/
Enter username and password and click on: * Services
Note: by Now you should see the localhost being monitored and some default services.

Httpd service will display a warning: HTTP WARNING: HTTP/1.1 403 Forbidden
Note: Just create an empty index.html page.
# touch /var/www/html/index.html
That should take care of the warning.

Nagios 3.4.4 looks a a lot better than previous versions.

That is it folks, that was easy.

by Renato de Oliveira

Monday, 18 February 2013

Installing and configuring Nagios NRPE from source


Install and configure Nagios NRPE and NPRE Plugins

Before you start some dependencies:

zlib-devel             
libsepol-devel         
libselinux-devel       
keyutils-libs-devel    
e2fsprogs-devel        
krb5-devel             
openssl-devel 

# cd /usr/local

# wgethttp://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fnagios%2Ffiles%2Fnrpe-2.x%2Fnrpe-2.14%2F&ts=1361216535&use_mirror=garr

# tar -zxvf nrpe-2.14.tar.gz

# cd nrpe-2.14


# ./configure --prefix=/usr/local/nagios


# make all

# adduser nagios

# mkdir /usr/local/nagios

# mkdir /usr/local/nagios/libexec

# mkdir /usr/local/nagios/share

# cp /usr/local/nrpe-2.14/src/nrpe /usr/local/nagios

# cp /usr/local/nrpe-2.14/src/check_nrpe /usr/local/nagios/libexec/

# cp /usr/local/nrpe-2.14/sample-config/nrpe.cfg /usr/local/nagios

# chown -R nagios: /usr/local/nagios

# add the line below to /etc/services on all servers to be monitored
nrpe 5666/tcp #NRPE



Modify /etc/xinetd.d/nrpe
Note: Do it on all servers and add the lines below:
# default: on
# description: NRPE
service nrpe
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = nagios
        server          = /usr/local/nagios/nrpe
        server_args     = -c /usr/local/nagios/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
        only_from       = <IPADDRESS of your Nagios Server>
}


# /etc/init.d/xinetd restart


# netstat -ant |grep 5666

Note: you should see a similar output as the one below
tcp     0    0 0.0.0.0:5666       0.0.0.0:* LISTEN

Installing Nagios NRPE plugins

# cd /usr/local

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

# tar -zxvf nagios-plugins-1.4.16.tar.gz

# cd nagios-plugins-1.4.16

# ./configure --prefix=/usr/local/nagios

# make all

# make install

NOTE: All plugins will be compiled and copied to /usr/local/nagios/libexec/

# chown nagios: -R /usr/local/nagios/libexec/

I will be writing about how to Install and configure Nagios server on next posts.

Something I would like to draw your attention to; once you have compiled the NRPE addon, you can simply tar the whole /usr/local/nagios folder and copy to remaining servers.

#tar -cvf nagios.tar /usr/local/nagios

by Renato