Chinaunix首页 | 论坛 | 博客
  • 博客访问: 461072
  • 博文数量: 237
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 0
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-12 14:40
个人简介

  每个人生的当口,都是会有一个孤独的时刻,四顾无人,只有自己,于是不得不看明白自己的脆弱,自己的欲望,自己的念想,自己的界限,还有,自己真正的梦想。

文章分类

全部博文(237)

文章存档

2017年(3)

2016年(234)

分类: LINUX

2016-05-11 11:05:14

原文地址: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
阅读(1483) | 评论(0) | 转发(0) |
0

上一篇:nagios安装及配置

下一篇:nagios部署安装

给主人留下些什么吧!~~