Skip to end of metadata
Go to start of metadata

Installing Nagios + N2RRD on CentOS/RHEL/Fedora

This document will guide you through installing Nagios and N2RRD package on top of CentOS/RHEL.

Nagios detailed configuration is covered by Nagios, so will not stress much here.

System Requirements

  • Hardware: This guide assumes you have a Intel/AMD based system, with minimum 4G RAM, enough disk space and access to internet is possible.
  • System Architecture: 64Bit (x86_64)
  • Operating System:  CentOS 6.3 (Should work for RHEL or Fedora Packages)
  • Apache: 2.x
  • Nagios: 3.2.3 (should work for any version greater than 3.x)
  • N2RRD: 1.4.6
  • Dependencies
  • Other tools

System Installation

CentOS installation

Download your desired version, basically a minimal version would do (e.g. CentOS-6.3-x86_64-minimal.iso) and burn it to CD.

once you are ready to go, put the CD into you system and start working through the console first.

Please note, the following steps will destroy any existing system and its data. So make sure that the system is new or the contents are backedup.

Initial Menu

Select "Install or Upgarde an existing system" and  press "TAB Key" to edit options

add option "text" as pointed above. This will start a text based installation.

This way you avoids graphical interface installtion and addtional graphical packages being installation, which you normally don't require.

Follow the instructions provided and once you are done and see the following prompt.

as instructed reboot your system and login as root.

Network Configuration

Network Setup

The following check list are example values used at test lab, that you have to change accordingly for your environment

Network Setup requirement/check list

VariableValuesComments
Hostnamemonitor 
Network interface nameeth0type /sbin/ifconfig -a would show you interface that are available with their names
System IP Address192.168.200.223 
Netmask255.255.255.0This may be different for you, check with your system or network administrator
Default gateway192.168.200.1 
DNS Server192.168.200.10 
Domain nameexample.com 

Setup Hostname

vi /etc/sysconfig/network

add or change variables as shown in figure above

Setup Network Interface

On RHEL you can use the text based tool "setup" to configure network interface or the following steps.

 

vi /etc/sysconfig/network-scripts/ifcfg-eth0

add or change the variable as pointed in above figure. The rest variables will be different on your system.

Setup DNS resolver

vi /etc/resolv.conf

make changes according to your environment.

Reboot System and test network

test network functionaly with system tool ping

ping -c 5 www.diglinks.com

 

Now you have configured the system and enabled networking.

Software packages installation

Create workspace for installation

Create a directory, where you would do all your downloads etc.

mkdir /usr/src/monitor
cd /usr/src/monitor

Install wget

this tool you would need often.

yum -y install wget

Install rpmforge repository configuration

Software version number will change with time

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Import GPG Keys from DAG

rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

Verify RPM package "rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm"

rpm -K rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Install downloaded RPM package

rpm -i rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Install version controll package

yum -y install subversion

Install RPM build package

yum -y install rpm-build

Install Apache Webserver Package

yum -y install httpd

Install nagios and nagios plugins

yum -y install  nagios nagios-plugins nagios-plugins-setuid nagios-nrpe perl-Nagios-Plugin perl-Nagios-Object perl-CGI perl-Log-Log4perl-RRDs

The above command will install

  • dependencies required by above listed packages
  • RRDTOOL package
  • Create User and Group Nagios

Install perl modules for RRDTOOL

yum -y install perl-RRD-Simple rrdtool-perl

Install N2RRD package

Download N2RRD package

wget http://n2rrd.diglinks.com/download/nagios-n2rrd-1.4.6-1.src.rpm

Install the source RPM

rpm -i nagios-n2rrd-1.4.6-1.src.rpm

Build RPM package, after changing directory to SPEC file location

cd ~/rpmbuild/SPECS/
rpmbuild -ba n2rrd.spec

Install N2RRD packages

rpm -i /root/rpmbuild/RPMS/noarch/nagios-n2rrd-1.4.6-1.noarch.rpm /root/rpmbuild/RPMS/noarch/nagios-n2rrd-rrd2graph-1.4.6-1.noarch.rpm

Verify if n2rrd is configured "nagios.cfg"

grep n2rrd /etc/nagios/nagios.cfg

Output of the above command

host_perfdata_command=n2rrd-process-host-perfdata

service_perfdata_command=n2rrd-process-service-perfdata

cfg_file=/etc/nagios/n2rrd.cfg

Rename RRA a template

cd /etc/n2rrd/templates/rra/
mv dist-default_execution_latency_el.t default_execution_latency_el.t

Create default nagiosadmin user and password for HTTP access

htpasswd -c /etc/nagios/htpasswd.users nagiosadmin

Verify if SELinux is enabled

sestatus

SELinux status:                 enabled

SELinuxfs mount:                /selinux

Current mode:                   enforcing

Mode from config file:          enforcing

Policy version:                 24

Policy from config file:        targeted

an output as above mean it is enabled, this will cause error while starting nagios. Actually Nagios RPM package should take care of SELinux issues, until then I would say, try to live without it.

Or fix it and please give me the steps.

Change mode from enforcing to permissive

This lets you start nagios without reboot. later you change SELinux config to do the same, which would be affective during system reboot.

echo 0 > /selinux/enforce

Disable or Change MODE to "permissive" SELinux

vi /etc/selinux/config

as pointed above change SELINUX to "disabled" or "permissive" and reboot your system.

Modify default nagios default configuration for localhost to display "rrd2graph" link

vi /etc/nagios/objects/localhost.cfg

Add following line to every service object that returns performance data.

notes_url                      /cgi-bin/rrd2graph.cgi?hostname=$HOSTNAME$&service=$SERVICEDESC$

Example config file with above line

Start Webserver(Apache) and Nagios Server

service start httpd
service start nagios

Firewall check

Last but least, check if your firewall is running and allows HTTP access to your system

service iptables status

Table: filter

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination

1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED

2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0

3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22

5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)

num  target     prot opt source               destination

1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)

num  target     prot opt source               destination

The above output shows no rules for HTTP (port 80)

vi /etc/sysconfig/iptables

add following line

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 

Restart Firewall

service iptables restart

 

Example config output

 

Congratulation you have now installed Nagios+N2RRD on CentOS

Connect to the server http://192.168.200.223/nagios

use username "nagiosadmin" and password you choose

Click "Services" side bar link, which would display following frame on the right side.

As pointed above click to see the graphs, well you may have to wait for sometime, so that atleast two samples are available for RRDTOOL.

Post installation and configuration

Disk Usage convert to Bytes

You might notice, with default setup the graphs are showing wrong values, this happens as the data stored in RRD is just a number and rrd doen't know if the input is

KB, MB, GB, TB, etc. The solution is to store the data as Bytes and the graph shows the data properly. For hits you have to enable options "DYN_DS_CONVERT_TO_BYTES" in n2rdd.conf.

vi /etc/n2rrd/n2rrd.conf

Search for variable name "DYN_DS_CONVERT_TO_BYTES" and change its value from default "0" to "1" as show below.

DYN_DS_CONVERT_TO_BYTES
# If enabled: if a value has UOM=KB|MB|GB|TB|PB|EB (see nagios plugin development document for UOM definition)
# then will convert them to Bytes, which scales automagically when graphing
# allowed 0|1
# 0 = disabled
# 1 = enabled
DYN_DS_CONVERT_TO_BYTES      = 1

You have to delete the RRD files if they were created before your changes to n2rrd.conf

 

 

  • No labels