Monday, September 7, 2015

Install Nagiosgraph on Centos 6

This article is on how to install Nagiosgraph on Centos.

Nagiosgraph is a plugin to Nagios and it provides graphical display of information captured by Nagios.

Installation environment:
Centos 6.5 x86_64
Nagios version 3.5.1-1
Pre-requisite perl modules: rrd tool 1.4+, Nagios::Config, GD, Object

Step 1: Prepare Nagiosgraph 1.5 for installation

# wget http://downloads.sourceforge.net/project/nagiosgraph/nagiosgraph/1.5.2/nagiosgraph-1.5.2.tar.gz
#  tar xvzf nagiosgraph-1.5.2.tar.gz
#  cd nagiosgraph-1.5.2
# less README

Install Perl module if havent installed.
# ./install.pl --check-prereq
# yum install perl-rrdtool perl-GD perl-Nagios-Plugin
# cpan Nagios::Config
If there are many modules not installed, just press Enter (Yes), unless you have other config.

Check all dependencies are met.
# ./install.pl --check-prereq


Step 2: Install Nagiosgraph source

# install.pl --prefix=/usr/share/nagiosgraph
Follow the instructions online. I choose the default values where nagios and httpd (apache) files were not updated automatically.

Step 3: Post configuration

If in step 2, it was chosen to not modify apache and nagios, then following must be configured. All instructions are printed at end of the installation of Step 3.

nagios.cfg
In the nagios configuration file (nagios.cfg),
    add/change these lines:
# vi /etc/nagios/nagios.cfg

Edit value for
process_performance_data=1

Add following lines
# process nagios performance data using nagiosgraph
service_perfdata_file=/tmp/perfdata.log
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata-for-nagiosgraph

template.cfg
# vi /etc/nagios/objects/templates.cfg
define service {
        name    graphed-service
        action_url      /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
        register 0
}

command.cfg
# vi /etc/nagios/objects/commands.cfg

# command to process nagios performance data for nagiosgraph
define command {
  command_name process-service-perfdata-for-nagiosgraph
  command_line /usr/share/nagiosgraph/bin/insert.pl
}

Host service files. E.g. for servername server1, append to show the graph service
vi  /etc/nagios/servers/server1.cfg
define service{
use generic-service,graphed-service
host_name applicationser1
service_description Current Load
check_command check_nrpe!check_load
}

* In the apache configuration file (httpd.conf),
    add this line:

include /usr/share/nagiosgraph/etc/nagiosgraph-apache.conf

Restart nagios to start data collection:
# service nagios restart

Restart apache to enable display of graphs:
# service httpd restart
Nagioschart: Chart icon in Nagios page

Nagioschart: Configuration page

Troubleshoot

Check graphs are displaying data, open a web browser and enter the URL
http://serversite/nagiosgraph/cgi-bin/show.cgi

Check RRD is collecting data with the command
# ls /usr/share/nagiosgraph/var/rrd

Check the nagios configuration files for errors
# /usr/sbin/nagios -v /etc/nagios/nagios.cfg

To enable graph links and mouseovers, see README sections:
       Displaying Per-Service and Per-Host Graph Icons and Links
       Displaying Graphs in Nagios Mouseovers

No comments:

Blog Archive