#!/bin/bash
#Author Karthikeyan.s
#Any Failing Command Will Cause The Script To Stop
set -e
#Treat Unset Variables As Errors
set -u
test $(id -u) -eq 0 || ( echo "You are not a root user to run this script " ; exit 1; )
echo "IMPORTANT: KINDLY MAKE SURE THAT YOU HAVE DISABLED SELINUX AND IPTABLES ........"
echo "NAGIOS INSTALLATION IS GOING TO BE START WITHIN 10 SECONDS......................"
sleep 5
echo "Nagios installation started : " `date`
echo "Installing Pre-requisites"
yum -y install httpd php
yum -y install gcc glibc glibc-common
yum -y install gd gd-devel
yum -y install openssl-devel
echo "Creating nagios user and setting password "
/usr/sbin/useradd -m nagios
echo "nagios" | /usr/bin/passwd --stdin nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
echo " Creating downloads folder in /opt directory "
mkdir /opt/downloads
cd /opt/downloads/
echo "Downloading Nagios and Nagios plugins "
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
tar -xvf nagios-3.2.3.tar.gz
cd nagios-3.2.3
echo "configuring Nagios"
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
echo "Set htpasswd for nagios"
htpasswd -nb nagiosadmin nagios > /usr/local/nagios/etc/htpasswd.users
/sbin/service httpd restart
cd ../
tar -xvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
echo "nagios Plugins "
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
/sbin/chkconfig --add nagios
/sbin/chkconfig nagios on
echo "verifying nagios "
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/sbin/service nagios start
echo "Nagios Installation finished successfully..."
No comments:
Post a Comment