nrpe自动安装脚本
时间:2010-09-01 来源:kennychang05
#!/bin/sh
#nrpe install script writed by sery([[email protected]),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!!!”
在linux及freebs下测试通过
请于此处下载 http://221.202.126.2/apmg/nrpe_install.tgz ,然后解包执行 ./setup.sh即可