Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1392718
  • 博文数量: 146
  • 博客积分: 1440
  • 博客等级: 少尉
  • 技术积分: 2996
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-24 23:47
个人简介

我一直在走,至少还有条路,也好于无路可走…

文章分类

全部博文(146)

文章存档

2024年(1)

2023年(1)

2017年(2)

2016年(5)

2015年(13)

2014年(13)

2013年(70)

2012年(41)

分类: LINUX

2012-12-12 13:56:15

#!/bin/bash 
echo 'tdjm v1.0 client by linuxhost'
echo '###########################################'
echo ''
clear
SOFTWARE_PATH=$(cd ~;pwd)
NAGIOS_PATH=/usr/local/nagios
PACKAGE1=gcc
PACHAGE2=glibc
PACKAGE3=xinetd
PACKAGE4=openssl
NAGIOS_SERVER=192.168.10.163      #插件位于nagios服务端的ftp上
. /etc/rc.d/init.d/functions
/usr/sbin/useradd -s /sbin/nologin nagios
######DownLoad The Client Package from Ftp Server######
download(){
echo 'DownLoad The Client Package from Ftp Server'
lftp $NAGIOS_SERVER <
cd /pub/ 
mget nagios-p.tar.gz
close 
bye
EOF
}

#############Installing The Client Package Of The Nagios-Plugins ########################
nagios-plugins() {
echo 'Installing The Client Package Of The Nagios-Plugins....'
tar -zxf nagios-p.tar.gz
echo "$SOFTWARE_PATH"
cd $SOFTWARE_PATH/nagios-p
tar zxvf nagios-plugins-1.4.15.tar.gz
cd $SOFTWARE_PATH/nagios-p/nagios-plugins-1.4.15
./configure
make all
make install
}
#############Installing The Client Package Of The Nrpe And IO-plu ########################
install-nrpe(){
echo 'Installing The Client Package Of The Nrpe'
cd $SOFTWARE_PATH/nagios-p
tar zxf nrpe-2.12.tar.gz
cd $SOFTWARE_PATH/nagios-p/nrpe-2.12
./configure
make all
make install-daemon
make install-daemon-config
make install-xinetd
if [ -f /etc/xinetd.d/nrpe ];then
sed -i "s/127.0.0.1/127.0.0.1 $NAGIOS_SERVER/g" /etc/xinetd.d/nrpe
else
echo 'NRPE requrie xinetd server!'
exit
fi
echo 'nrpe            5666/tcp                        # nrpe' >> /etc/services

#install vmio
cd $SOFTWARE_PATH/nagios-p
tar -zxf VMIO.tar.gz
cp Nagios_VIMO_Plugin/check_vmio.sh $NAGIOS_PATH/libexec

#chenge owner
chown -R nagios:nagios $NAGIOS_PATH
}
#############################Add The Client Check Command###########################
add-command() {
if [ -f $NAGIOS_PATH/etc/nrpe.cfg ];then
sed -i '/check_users/d' $NAGIOS_PATH/etc/nrpe.cfg
sed -i '/check_load/d' $NAGIOS_PATH/etc/nrpe.cfg
cat >>$NAGIOS_PATH/etc/nrpe.cfg<
#####################################################
command[check_users]=/usr/local/nagios/libexec/check_users -w 10 -c 15
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,12,10 -c 25,20,18
command[check_disk]=/usr/local/nagios/libexec/check_disk -x /ytxt/patch -x /ytxt/maintain -w 10% -c 5%
command[check_procs]=/usr/local/nagios/libexec/check_procs -w 280 -c 350
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 8% -c 4%
command[check_vmio]=/usr/local/nagios/libexec/check_vmio.sh -p PROCESS_QUEUE -w 10 -c 15
EOF

else
echo 'The Nagios-plugins Install Fail!'
exit
fi
}
main(){
for i in $PACKAGE1 $PACKAGE2 $PACKAGE3 $PACKAGE4
do
rpm -q $i >/dev/null 2>&1
if (($? != 0));then
echo "PLE chack $i package"
exit
else
echo 'The base package have installed!'
fi
done
download
nagios-plugins
install-nrpe
add-command
sed -i 's/allowed_hosts=127.0.0.1/allowed_hosts=127.0.0.1,192.168.10.163/g' /usr/local/nagios/etc/nrpe.cfg
echo '/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d' >> /etc/rc.d/rc.local
rm -rf /etc/xinetd.d/nrpe

#restart xinetd
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
sleep 5

netstat -natuple | grep 5666 >/dev/null 2>&1
if (($? != 0));then
echo
echo
echo
echo '#########################################################'
echo '#Install Fail Please Check The Server And install again!#'
echo '#########################################################'
else
echo
echo 
echo '###########################################'
echo '#                 INSTALL SUCCESS         #'
echo '###########################################'
fi
}
if grep nagios /etc/passwd
then
main
else
echo 'you must add the nagios user!'
exit 0
f
阅读(1884) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~