Groundwork, Nagios and SNMP Traps Integration....!!

Pre Requisites
Minimal installation of CentOS with base package

Disabling selinux
vi /etc/selinux/config
SELINUX=disabled

Yum –y install gcc
cd /usr/src/
wget http://search.cpan.org/CPAN/authors/id/N/NW/NWCLARK/perl-5.8.9.tar.bz2
tar xvf perl-5.8.9.tar.bz2
cd perl-5.8.9
./configure.gnu --prefix=/usr
make
make test
make install

Installing perl modules
perl -MCPAN -e shell
install Text::ParseWords
install Getopt::Long
install Config::IniFiles
install Time::HiRes
install Sys::Hostname
install File::Basename
install Text::Balanced

Installing groundwork
chmod +x groundwork-5.3.0-br46-gw333-linux-32-installer.bin
./groundwork-5.3.0-brXX-gwYYY-linux-32-installer.bin --mode text

Installing net-snmp
yum -y install net-snmp
download net-snmp package to /usr/src (http://www.net-snmp.org)
tar xvzf net-snmp-5.4.2.1.tar.gz
cd net-snmp-5.4.2.1
./configure --with-perl-modules
make
make test
make install

Installing snmptt
tar xvzf snmptt_1.2.tgz
cd /usr/src/snmptt_1.2
cp snmptt /usr/sbin/
cp snmptthandler /usr/sbin/
cd /usr/sbin/
chmod +x snmptt
chmod +x snmptthandler
cd /usr/src/snmptt_1.2
cp snmptt.ini /etc/snmp/
cd /etc/snmp/
create a new file;
vi snmptrapd.conf
and add the following line;
traphandle default /usr/sbin/snmptt

vi /etc/init.d/snmptrapd
Change the OPTIONS="-Lsd -p /var/run/snmptrapd.pid" as below
OPTIONS="-On -Lsd -p /var/run/snmptrapd.pid"

/etc/init.d/snmptrapd restart
cp /usr/src/snmptt_1.2/snmptt-init.d /etc/init.d/snmptt
cd /etc/init.d/
chmod 755 snmptt
chkconfig --add snmptt
chkconfig --level 2345 snmptt on
/etc/init.d/snmptt start

cp /usr/src/snmptt_1.2/snmpttconvert /usr/bin
cp /usr/src/snmptt_1.2/snmpttconvertmib /usr/bin
cd /usr/bin/
chmod 755 snmpttconvert

chmod 755 snmpttconvertmib

snmptt.ini configurations with following values (/etc/snmp/snmptt.ini)
dns_enable = 1
strip_domain = 1
net_snmp_perl_enable = 1
pre_exec_enable = 0
unknown_trap_log_enable = 1


/etc/init.d/snmptt start

Opening 80 port from the firewall
vi /etc/sysconfig/iptables
add the following line
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
/etc/init.d/iptables restart

Access groundwork through a web browser
User name: admin
P/w: admin

Enable notifications
Go to Control --> Nagios main Configurations --> Enable notifications: check the box --> save --> commit

Adding a host
Go to Configuration --> Host Wizard and follow steps Go to Control --> commit --> commit

Submit-check-results
Download submit_check_result from nagios standard distribution
Copy it to /usr/local/groundwork/nagios/eventhandlers/

chmod +x submit_check_result
vi submit_check_result
and change the nagios.cmd file path
/usr/local/groundwork/nagios/var/spool/nagios.cmd

Compiling a MIB
snmpttconvertmib --in= --out=/etc/snmp/snmptt.conf1 --net_snmp_perl

Edit the compiled file and add the following to each and every trap
EXEC /usr/local/groundwork/nagios/eventhandlers/submit_check_result $R TRAP 1 "$*"

Add compiled file paths to the /etc/snmp/snmptt.ini script [...]
[TrapFiles]
snmptt_conf_files = << END
/etc/snmp/snmptt.conf1
/etc/snmp/snmptt.conf2
END

Creating TRAP service
Create a new service with following details

Name : TRAP
use :generic-service
is_volatile :1
check_command :check-host-alive
max_check_attempts :1
normal_check_interval :1
retry_check_interval :1
passive_checks_enabled :1 Active_checks_enabled :0
check_period :24/7
notification_interval :31536000
contact_groups :somegroup

To enable audio alerts edit the following file.
/usr/local/groundwork/apache2/confg/httpd.conf
Add following lines.

ScriptAlias /nagios/cgi-bin "/usr/local/groundwork/nagios/sbin"
< Directory "/usr/local/groundwork/nagios/sbin">
# Uncomment for Guava Single Sign On
AuthType Basic
require valid-user
# The following line should be change to specify the default page for invalid access attempts to this directory
TKTAuthLoginURL http://localhost:80/monitor/index.php
TKTAuthCookieName nagios_auth_tkt
TKTAuthTimeout 0
# Uncomment to disable Guava Single Sign On
# AllowOverride AuthConfig
# Options ExecCGI
# Order allow,deny
# Allow from all
PassEnv LD_LIBRARY_PATH
PassEnv NAGIOS_CGI_CONFIG
< /directory>

Alias /nagios/media "/usr/local/groundwork/nagios/share/media"
< Directory "/usr/local/groundwork/nagios/share/media">
# Uncomment for Guava Single Sign On
AuthType Basic
require valid-user
# The following line should be change to specify the default page for invalid access attempts to this directory
TKTAuthLoginURL http://localhost:80/monitor/index.php
TKTAuthCookieName nagios_auth_tkt
TKTAuthTimeout 0
< /directory>

2 comments:

Anonymous said...

Very handy post. I have the following comments:

Why is your blog using grey on black text? :-)

My installation of Groundwork has a slightly wonky perl installation, which I think may be common to other folk. The result was that snmptt couldn't start as PERL couldn't find the libraries. I fixed this by adding the line:
export PERL5LIB=/usr/local/groundwork/perl/lib/5.8.8
to /etc/init.d/snmptt

submit_check_results can be downloaded from the icinga web site (a fork of Nagios

Until you have converted MIBs, each time you start snmptt, you will get errors about snmptt.conf not being at the expected location. Worth adding inline to the text.

Many thanks for sharing this!

Developing Effectiveness said...

its a gud post and valuable .. keep up the gud work

FZL

Hi Friends,,,