#!/bin/sh
################################################
#this scripts is created by oldboy
#site:http://www.etiantian.org
#blog:http://oldboy.blog.51cto.com
################################################
NAGIOS_TOOLS_DIR=/home/oldboy/tools
NAGIOS_INSTALL_DIR=/usr/local/nagios echo "------ step 1: config yum ------"
cd /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo echo "------ step 2: config profile------"
echo 'export LC_ALL=C'>> /etc/profile
source /etc/profile echo "------ step 3: stop iptables and selinux------"
/etc/init.d/iptables stop
/etc/init.d/iptables stop
chkconfig iptables off
setenforce
if [ -f /etc/selinux/config ]; then
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce
fi
echo "------ step 4: config time sync------"
/usr/sbin/ntpdate pool.ntp.org
echo '#time sync by oldboy at 2010-2-1'>>/var/spool/cron/root
echo '*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1'>>/var/spool/cron/root
crontab -l echo "------ step 5: install gcc and lamp env etc------"
yum install gcc glibc glibc-common -y
yum install gd gd-devel -y
yum install httpd php php-gd -y
yum install mysql* -y echo "------ step 6: add nagios user and group------"
/usr/sbin/useradd -m nagios
#/usr/sbin/useradd apache
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache echo "------ step 7: download and install nagios------" [ ! -f oldboy_training_nagios_soft.zip ] && exit unzip oldboy_training_nagios_soft.zip tar xzf nagios-3.5..tar.gz cd nagios ./configure --with-command-group=nagcmd make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cd ../ echo "------ step 8: config web auth------"
htpasswd -cb /usr/local/nagios/etc/htpasswd.users oldboy echo "------ step 9: install nagios-plugins------"
yum -y install perl-devel
tar zxf nagios-plugins-1.4..tar.gz
cd nagios-plugins-1.4.
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
make && make install
cd ../
ls /usr/local/nagios/libexec/|wc -l echo "------ step 10: install nrpe------"
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
cd .. echo "------ step 11: startup service and check------"
/etc/init.d/nagios start
/etc/init.d/httpd start
echo -----------
lsof -i tcp:
echo ----------
ps -ef|grep nagios
echo "NAGIOS is successfully installed."
echo ok
05-11 22:26