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

详解搭建Linux监控平台之Nagios

被监控端的环境部署

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

这次被监控主要有2种:

1.web服务器

2.mysql服务器

所以得先保证nginx/apache 或者mysql服务的启动;

下面是mysql监控端部署的函数installmysql () 脚本如下

  1. installmysql () {
  2. yum install xinetd -y
  3. service xinetd start
  4. cd $path
  5. useradd -s /sbin/nologin nagios
  6. tar -zxvf nagios-plugins-1.4.14.tar.gz
  7. cd nagios-plugins-1.4.14
  8. ./configure --prefix=$nagiospath --with-nagios-user=nagios --with-nagios-group=nagios
  9. make
  10. make install
  11. cd $path
  12. tar -zxvf nrpe-2.12.tar.gz
  13. cd nrpe-2.12
  14. ./configure
  15. make all
  16. make install
  17. make install-plugin
  18. make install-daemon
  19. make install-daemon-config
  20. make install-xinetd
  21. read -p " Please input the nagios server IP: " serverip
  22. echo "nrpe 5666/tcp #nrpe" >> /etc/services
  23. sed -i "s#only_from.*#only_from = 127.0.0.1 $serverip#" /etc/xinetd.d/nrpe
  24. chkconfig --add xinetd
  25. chkconfig xinetd on
  26. cd $path
  27. tar -zxvf check_mysql_health-2.1.tar.gz
  28. cd check_mysql_health-2.1
  29. ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl
  30. make
  31. make install
  32. yum install perl-DBI perl-DBD-MySQL -y
  33. cd $path
  34. tar -zxvf check_iftraffic.tar.gz
  35. chmod +x check_iftraffic
  36. chmod +x check_mem.sh
  37. chmod +x check_cpu.sh
  38. chmod +x ip_conn.sh
  39. cp check_mem.sh /usr/local/nagios/libexec
  40. cp check_cpu.sh /usr/local/nagios/libexec
  41. cp check_iftraffic /usr/local/nagios/libexec
  42. cp ip_conn.sh /usr/local/nagios/libexec
  43. read -p "please input the mysql password: " mysqlpwd
  44. read -p "please input the nagios for mysql's password: " nagiospwd
  45. mysql -uroot -p$mysqlpwd -e "create database nagios;"
  46. mysql -uroot -p$mysqlpwd -e "grant select on nagios.* to nagios@'$serverip' identified by '$nagiospwd' ;"
  47. mysql -uroot -p$mysqlpwd -e "flush privileges; "
  48. cp $path/cfg/nrpe.cfg /usr/local/nagios/etc/
  49. chown -R nagios.nagios /usr/local/nagios
  50. service xinetd restart
  51. echo "##############################"
  52. echo "#########**the result**#######"
  53. lsof -i:5666
  54. echo "------------------------------"
  55. /usr/local/nagios/libexec/check_nrpe -H localhost
  56. }

下面是web端部署的脚本

  1. installweb () {
  2. yum install xinetd -y
  3. service xinetd start
  4. cd $path
  5. useradd -s /sbin/nologin nagios
  6. tar -zxvf nagios-plugins-1.4.14.tar.gz
  7. cd nagios-plugins-1.4.14
  8. ./configure --prefix=$nagiospath --with-nagios-user=nagios --with-nagios-group=nagios
  9. make
  10. make install
  11. cd $path
  12. tar -zxvf nrpe-2.12.tar.gz
  13. cd nrpe-2.12
  14. ./configure
  15. make all
  16. make install
  17. make install-plugin
  18. make install-daemon
  19. make install-daemon-config
  20. make install-xinetd
  21. read -p " Please input the nagios server IP: " serverip
  22. echo "nrpe 5666/tcp #nrpe" >> /etc/services
  23. sed -i "s#only_from.*#only_from = 127.0.0.1 $serverip#" /etc/xinetd.d/nrpe
  24. chkconfig --add xinetd
  25. chkconfig xinetd on
  26. cd $path
  27. tar -zxvf check_iftraffic.tar.gz
  28. chmod +x check_iftraffic
  29. chmod +x check_mem.sh
  30. chmod +x check_cpu.sh
  31. chmod +x ip_conn.sh
  32. cp check_mem.sh /usr/local/nagios/libexec
  33. cp check_cpu.sh /usr/local/nagios/libexec
  34. cp check_iftraffic /usr/local/nagios/libexec
  35. cp ip_conn.sh /usr/local/nagios/libexec
  36. cp $path/cfg/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg
  37. chown -R nagios.nagios /usr/local/nagios
  38. service xinetd restart
  39. echo "###################################"
  40. echo "######### the result ########"
  41. echo "-----------------------------------"
  42. lsof -i:5666
  43. echo "-----------------------------------"
  44. /usr/local/nagios/libexec/check_nrpe -H localhost
  45. }
  • 验证安装是否成功的方式,与第一篇相同

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

       

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