nrpe自动安装脚本

  1. #!/bin/sh  
  2. #nrpe install script writed by sery([email=sery@163.com),2009-11-23]  
  3.  
  4. Os_is=`uname`  
  5. Nagios_is=`grep nagios /etc/passwd | wc -l`  
  6.  
  7. if [ "$Os_is" = "Linux" ]  
  8. then  
  9.   ipadd=$(ifconfig | sed -n ‘2p’|awk ‘{print $2}’|awk -F: ‘{print $2}’)  
  10.   if [ $Nagios_is = 0 ]  
  11.   then  
  12.     useradd nagios -s /sbin/nologin  
  13.   fi  
  14. elif [ "$Os_is" = "FreeBSD" ]  
  15.    then  
  16.     ipadd=$(ifconfig | sed -n ‘4p’|awk ‘{print $2}’)  
  17.     if [ $Nagios_is = 0 ]  
  18.     then  
  19.     /usr/sbin/pw useradd nagios -s /sbin/nologin  
  20.     fi  
  21. else echo “this is other os,please modify the script”  
  22. exit 1  
  23. fi  
  24.  
  25. #install nrpe  
  26. PREFIX=/usr/local/nrpe  
  27. tar zxvf nrpe-2.12.tar.gz  
  28. cd nrpe-2.12  
  29. ./configure –prefix=$PREFIX  
  30. make  
  31. make install  
  32. echo “nrpe install ok….!”  
  33. sleep 3  
  34.  
  35. cd ..  
  36. if [ ! -d $PREFIX/etc ]  
  37.    then  
  38.      mkdir $PREFIX/etc  
  39. fi  
  40.  
  41. #install nagios-plugins  
  42. tar zxvf nagios-plugins-1.4.14.tar.gz  
  43. cd nagios-plugins-1.4.14  
  44. ./configure –prefix=$PREFIX  
  45. make  
  46. make install  
  47. cd ..  
  48. echo “nagios-plugins is ok!”  
  49. sleep 3  
  50.  
  51. #setting nrpe  
  52. cp ip_conn.sh $PREFIX/libexec  
  53. chmod -R +x $PREFIX/libexec  
  54. sed -e /^server_add/s/$/”$ipadd”/ -e /^allowed_hosts/s/$/$ipadd/ nrpe.cfg > $PREFIX/etc/nrpe.cfg  
  55. #running nrpe  
  56. cd $PREFIX  
  57. bin/nrpe -c etc/nrpe.cfg -d  
  58. echo “haha! nrpe is running!!!” 


在linux及freebs下测试通过
请于此处下载 http://221.202.126.2/apmg/nrpe_install.tgz 或者本地下载,然后解包执行 ./setup.sh即

本日志由 flyinweb 于 2010-05-27 17:28:23 发表,目前已经被浏览 3959 次,评论 0 次;

作者添加了以下标签: nrpe

引用通告:http://www.517sou.net/Article/452/Trackback.ashx

评论订阅:http://www.517sou.net/Article/452/Feeds.ashx

评论列表

    暂时没有评论
(必填)
(必填,不会被公开)