Shell脚本 自动安装nrpe

nrpe自动安装脚本
#!/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!!!”

本文出自 “nightmare” 博客,转载请与作者联系!

你可能感兴趣的:(职场,nrpe,休闲)