Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2886780
  • 博文数量: 348
  • 博客积分: 2907
  • 博客等级: 中校
  • 技术积分: 2272
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-12 09:16
个人简介

专注 K8S研究

文章分类

全部博文(348)

文章存档

2019年(22)

2018年(57)

2016年(2)

2015年(27)

2014年(33)

2013年(190)

2011年(3)

2010年(14)

分类: LINUX

2014-03-24 13:38:23

原文地址:nagios客户端部署脚本 作者:baochenggood

#!/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
阅读(1804) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~