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

详解搭建Linux监控平台之Nagios

使用以及相关说明

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

使用及相关如下:
 
使用脚本如下配套之前的函数:

  1. addservices () {
  2. echo "you can add services for web-server or mysql-server "
  3. echo "1,web-server"
  4. echo "2,mysql-server"
  5. echo "3,exit"
  6. read abc
  7. case $abc in 1)
  8. webservices ;;
  9. 2)
  10. echo "you can change the mysql type"
  11. echo "1,master server"
  12. echo "2,slave server"
  13. read abcd
  14. if [ $abcd == 1 ]
  15. then
  16. #installclientmysql
  17. addmysqlservicemaster
  18. else
  19. #installclientmysql
  20. addmysqlserviceslave
  21. fi
  22. echo " " ;;
  23. 3)
  24. exit ;;
  25. esac
  26. }
  27. actionserver () {
  28. echo "this is at nagios server:you can change install environment or add services"
  29. echo "1,Install environment for nagios;"
  30. echo "2,add the client services!!!!!!!!!"
  31. read aaa
  32. case $aaa in 1)
  33. installserver
  34. addnagios ;;
  35. 2)
  36. addservices ;;
  37. *)
  38. echo "this is error,please change again."
  39. actionserver ;;
  40. esac
  41. }
  42. actionclient () {
  43. echo "this is at nagios client:you can install the different environment"
  44. echo "1,install the environment for web-server!!"
  45. echo "2,install the environment for mysql-server"
  46. read bbb
  47. case $bbb in 1)
  48. installweb ;;
  49. 2)
  50. installmysql ;;
  51. 3)
  52. echo "this is error,please change again"
  53. actionclient ;;
  54. esac
  55. }
  56. echo "######################################"
  57. echo "######**this is nagios scripts**######"
  58. echo "you can change this action:"
  59. echo "1,if you at the nagios server,please check it out!!"
  60. echo "2,if you at the nagios client,please check it out!!"
  61. read asd
  62. case $asd in 1)
  63. actionserver ;;
  64. 2)
  65. actionclient ;;
  66. *)
  67. exit ;;
  68. esac

解压完nagios.tar.gz后会出现一个naigos文件夹,进入文件夹执行./install

如果我们在监控端就选择:1

选择 1 后会出现下面

这是选择1:就是开始部署监控端的环境  2:开始添加服务

当我们选择添加服务时:

这时选择1:添加web服务器类型的服务

2:mysql服务器器类型的服务

mysql服务器类型服务

注意一下:目前就支持主服务器的类型,备注:从服务器的还不支持(脚本里面有个函数,你可以自己修改这样也是可以的)  所以请选择1

这样在监控端的操作就完成了

备注:如果数字敲错可以ctrl+删除键 这样可以删除输入的数字

如果我们在被监控端选择: 2

这时,根据自己被监控端服务器类型进行选择就可以了

结果如下:

这样具体添加了那些服务 看图比较直接

相关补充:

1,报警频率的设置

  1. define service{
  2. host_name $host
  3. service_description Linux-load
  4. check_command check_nrpe!check_load
  5. max_check_attempts 5
  6. normal_check_interval 3
  7. retry_check_interval 2
  8. check_period 24x7
  9. notification_interval 10
  10. notification_period 24x7
  11. notification_options w,u,c,r
  12. contact_groups mysql-server
  13. }

max_check_attempts      5    检测异常后最多检测5次后就报警

normal_check_interval  3    每3分钟检测一次

retry_check_interval    2    一旦检测异常后每2分钟检测一次

notification_interval  10  邮件报警的频率 10就是代表10分钟发送一次

我对normal_check_interval 有点疑问 好像你设置成多少 naigos自身好像是30秒或1分钟自己检测一次

所以理论上当服务发生异常时的报警时间:3+(2*4)=13 然后每10分钟发送一次邮件

当然对于比较重要的服务可以适当调整

2,对nagios报警邮件的限制

  1. define hostescalation{
  2. host_name $host
  3. first_notification 5
  4. last_notification 0
  5. notification_interval 10
  6. contact_groups mysql-server
  7. }
  8. define serviceescalation{
  9. host_name $host
  10. service_description Mysql-Listener
  11. first_notification 5
  12. last_notification 0
  13. notification_interval 10
  14. contact_groups mysql-server
  15. }
  16. define serviceescalation{
  17. host_name $host
  18. service_description Mysql-Status
  19. first_notification 5
  20. last_notification 0
  21. notification_interval 10
  22. contact_groups mysql-server
  23. } " >> /usr/local/nagios/etc/objects/escalations.cfg

这可以通过创建escalations.cfg进行设置 
 
 
                host_name              $host
 
                service_description    Mysql-Listener     
 
                first_notification      5        从第五份邮件开始
 
                last_notification      0        从第x封结束调整
 
                notification_interval  10      发送频率10 即10分钟发送一次
 
                contact_groups          mysql-server
 
host_name 要与hosts.cfg中的一致
 
service_description 要与services.cfg一致
 
contact_groups 与contactgroup.cfg一致
 
具体参数可以自己调整
 
具体报警的邮箱在contacts.cfg里面修改就可以了  默认使用sendmail发送 所以记得开启sendmail服务               
 
nagios安装包(里面包含了lamp)地址如下:

 

下载在Linux公社的1号FTP服务器里,下载地址:

FTP地址:ftp://www.linuxidc.com

用户名:www.6688.cc

密码:www.linuxidc.com

在 2012年LinuxIDC.com\11月\详解搭建Linux监控平台之Nagios\Nagios安装包

下载方法见 http://www.linuxidc.net/thread-1187-1-1.html

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

       

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