手机版
你好,游客 登录 注册
背景:
阅读新闻

详解搭建Linux监控平台之Nagios

监控端环境部署

[日期:2012-11-29] 来源:Linux社区  作者:vbbb625 [字体:大 中 小]

这个只是总体脚本中的监控端的一个函数 installserver ()
 
具体脚本如下:

  1. #!/bin/bash
  2. #this is nagios server or client install shell
  3. #at 2012/10/29
  4. path=`pwd`
  5. httppath=/usr/local/apache2
  6. mysqlpath=/usr/local/mysql
  7. nagiospath=/usr/local/nagios
  8. installserver () {
  9. yum install -y xinetd
  10. useradd -m nagios
  11. groupadd nagcmd
  12. useradd -a -G nagcmd nagios
  13. useradd -a -G nagcmd apache
  14. cd $path
  15. tar -zxvf nagios-3.2.0.tar.gz
  16. cd nagios-3.2.0
  17. ./configure --with-command-group=nagcmd--with-nagios-user=nagios --with-nagios-group=nagios
  18. make all
  19. make install
  20. make install-init
  21. make install-config
  22. make install-commandmode
  23. make install-webconf
  24. echo "########################################"
  25. echo "please create the nagios user for apache"
  26. echo "----------------------------------------"
  27. cat $path/http.txt >> /etc/httpd/httpd.conf
  28. $httppath/bin/htpasswd -c $nagiospath/etc/htpasswd.users nagiosadmin
  29. chkconfig --add nagios
  30. chkconfig nagios on
  31. cd $path
  32. tar -zxvf nagios-plugins-1.4.14.tar.gz
  33. cd nagios-plugins-1.4.14
  34. ./configure --prefix=$nagiospath --with-nagios-user=nagios --with-nagios-group=nagios
  35. make
  36. make install
  37. cd $path
  38. tar -zxvf nrpe-2.12.tar.gz
  39. cd nrpe-2.12
  40. ./configure
  41. make all
  42. make install
  43. make install-plugin
  44. make install-daemon
  45. make install-daemon-config
  46. make install-xinetd
  47. read -p " Please input the nagios server IP: " serverip
  48. echo "nrpe 5666/tcp #nrpe" >> /etc/services
  49. sed -i "s#only_from.*#only_from = 127.0.0.1 $serverip#" /etc/xinetd.d/nrpe
  50. chkconfig --add xinetd
  51. chkconfig xinetd on
  52. service xinetd restart
  53. cd $path
  54. tar -zxvf check_mysql_health-2.1.tar.gz
  55. cd check_mysql_health-2.1
  56. ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl
  57. make
  58. make install
  59. yum install perl-DBI perl-DBD-MySQL -y
  60. cd $path
  61. tar -zxvf check_iftraffic.tar.gz
  62. chmod +x check_iftraffic
  63. chmod +x check_mem.sh
  64. chmod +x check_cpu.sh
  65. chmod +x ip_conn.sh
  66. cp check_mem.sh /usr/local/nagios/libexec
  67. cp check_cpu.sh /usr/local/nagios/libexec
  68. cp check_iftraffic /usr/local/nagios/libexec
  69. cp ip_conn.sh /usr/local/nagios/libexec
  70. mv $path/cfg/server/etc/* /usr/local/nagios/etc
  71. mv $path/cfg/server/objects/* /usr/local/nagios/etc/objects
  72. chown -R nagios.nagios /usr/local/nagios
  73. service httpd restart
  74. service xinetd restart
  75. echo "###################################"
  76. echo "######### the result ########"
  77. echo "-----------------------------------"
  78. /usr/sbin/lsof -i:5666
  79. echo "-----------------------------------"
  80. /usr/local/nagios/libexec/check_nrpe -H localhost
  81. }

悲剧的是

/usr/sbin/lsof -i:5666

echo "-----------------------------------"

/usr/local/nagios/libexec/check_nrpe -H localhost

还得手动敲命令,

正常得到的结果如下:

这样就代表安装成功了

补充一下:nagios+lamp的统一安装包将在后面放出

linux
【内容导航】
第1页:LAMP环境 第2页:监控端环境部署
第3页:被监控端的环境部署 第4页:监控端添加服务
第5页:使用以及相关说明
相关资讯       Nagios 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款