Chinaunix首页 | 论坛 | 博客
  • 博客访问: 256413
  • 博文数量: 24
  • 博客积分: 179
  • 博客等级: 入伍新兵
  • 技术积分: 1859
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-30 13:11
文章分类
文章存档

2014年(4)

2011年(2)

2010年(18)

分类: 系统运维

2010-10-14 16:47:38

要监控一个规模大一些的网络,如果纯粹手工部署nrpe到每个服务器,既容易出错,又没有效率。要解决这个问题,使用脚本是一个比较理想的方式。
我已经把NRPE所需的文件打包归档,读者可以从.202.126.2/ apmg/nrpe_install.tgz下载,解包后进入目录,然后运行./setup.sh即可完成安装和配置的全部操作。
 

安装脚本setup.sh的内容如下:

#!/bin/sh
#nrpe install script writed by sery(sery@163.com),2009-11-23
Os_is=`uname`
Nagios_is=`grep nagios /etc/passwd | wc -l`
if [ "$Os_is" = "Linux" ]
then
  ipadd=$(ifconfig | sed -n '2p'|awk '{print $2}'|awk -F: '{print $2}')
  if [ $Nagios_is = 0 ]
  then
    useradd nagios -s /sbin/nologin
  fi
elif [ "$Os_is" = "FreeBSD" ]
   then
    ipadd=$(ifconfig | sed -n '4p'|awk '{print $2}')
    if [ $Nagios_is = 0 ]
    then
    /usr/sbin/pw useradd nagios -s /sbin/nologin
    Fi
else echo "this is other os,please modify the script"
exit 1
fi
#install nrpe
PREFIX=/usr/local/nrpe
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure --prefix=$PREFIX
Make
make install
echo "nrpe install ok....!"
sleep 3
cd ..
if [ ! -d $PREFIX/etc ]
   then
     mkdir $PREFIX/etc
fi
#install nagios-plugins
tar zxvf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14
./configure --prefix=$PREFIX
Make
make install
cd ..
echo "nagios-plugins is ok!"
sleep 3
#setting nrpe
cp ip_conn.sh $PREFIX/libexec
chmod -R +x $PREFIX/libexec
sed -e /^server_add/s/$/"$ipadd"/ -e /^allowed_hosts/s/$/$ipadd/
nrpe.cfg > $PREFIX/etc/nrpe.cfg
#running nrpe
cd $PREFIX
bin/nrpe -c etc/nrpe.cfg –d
echo "haha! nrpe is running!!!"
 
 
 
 
阅读(2386) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~