Centos系统下载大全 | Redhat系统下载大全 | Windows2012系统下载大全 | Windows2008系统下载大全| CMS教程 | 网站地图 51运维网-专注Linux/Unix系统安全运维!
当前位置:51运维网 > 监控 > Nagios > 正文

搭建linux监控平台之nagios

时间:2013-12-26 12:54 来源:未知 作者:51ou.com 阅读:
被监控端工作已经做好了,现在就只要在监控端进行操作了;

注意一下:被监控中mysql记得要设密码啊

添加服务类型也是2种:

1.web服务器

2.mysql服务器

下面是添加web服务的脚本:

 

  1. webservices () { 
  2.  read -p " Please input the web server IP: " webip 
  3.  read -p "please input the web alias name : "  host 
  4.  echo "define host{ 
  5.          host_name                       $host 
  6.          alias                           web-server 
  7.          address                         $webip 
  8.          check_command                   check-host-alive 
  9.          max_check_attempts              5 
  10.          check_period                    24x7 
  11.          contact_groups                  web-server 
  12.          notification_interval           10 
  13.          notification_period             24x7 
  14.          notification_options            d,u,r 
  15.          }" >> /usr/local/nagios/etc/objects/hosts.cfg 
  16.  sed -i "6,10{/members/s/$/,$host/}" /usr/local/nagios/etc/objects/hostgroups.cfg 
  17.   
  18.  echo " 
  19.  define hostescalation{  
  20.                  host_name               $host        
  21.                  first_notification      5                  
  22.                  last_notification       0                  
  23.                  notification_interval   10                
  24.                  contact_groups          web-server              
  25.                  }  
  26.  define serviceescalation{  
  27.                  host_name               $host  
  28.                  service_description     Nginx-Listener        
  29.                  first_notification      5  
  30.                  last_notification       0  
  31.                  notification_interval   10  
  32.                  contact_groups          web-server  
  33.                  }  
  34.  define serviceescalation{  
  35.                  host_name               $host  
  36.                  service_description     Linux-PHP-procs        
  37.                  first_notification      5  
  38.                  last_notification       0  
  39.                  notification_interval   10  
  40.                  contact_groups          web-server  
  41.                  }  
  42.  define serviceescalation{  
  43.                  host_name               $host  
  44.                  service_description     Linux-iftraffic        
  45.                  first_notification      5  
  46.                  last_notification       0  
  47.                  notification_interval   10  
  48.                  contact_groups          web-server  
  49.                  }  
  50.  define serviceescalation{  
  51.                  host_name               $host  
  52.                  service_description     check-ips        
  53.                  first_notification      5  
  54.                  last_notification       0  
  55.                  notification_interval   10  
  56.                  contact_groups          web-server  
  57.                  } " >> /usr/local/nagios/etc/objects/escalations.cfg  
  58.   
  59.  echo " 
  60.      define service{ 
  61.          host_name               $host 
  62.          service_description     check-host-alive 
  63.          check_command           check-host-alive 
  64.          max_check_attempts      4 
  65.          normal_check_interval   3 
  66.          retry_check_interval    2 
  67.          check_period            24x7 
  68.          notification_interval   10 
  69.          notification_period     24x7 
  70.          notification_options    w,u,c,r 
  71.          contact_groups          web-server 
  72.          } 
  73.       define service{ 
  74.          host_name               $host 
  75.          service_description     disk-/ 
  76.          check_command           check_local_disk!10%!5%!/ 
  77.          max_check_attempts      4 
  78.          normal_check_interval   3 
  79.          retry_check_interval    2 
  80.          check_period            24x7 
  81.          notification_interval   10 
  82.          notification_period     24x7 
  83.          notification_options    w,u,c,r 
  84.          contact_groups          web-server 
  85.          } 
  86.       define service{ 
  87.          host_name               $host 
  88.          service_description     SSH-Listener 
  89.          check_command           check_tcp!22 
  90.          max_check_attempts      4 
  91.          normal_check_interval   3 
  92.          retry_check_interval    2 
  93.          check_period            24x7 
  94.          notification_interval   10 
  95.          notification_period     24x7 
  96.          notification_options    w,u,c,r 
  97.          contact_groups          web-server 
  98.          } 
  99.       define service{ 
  100.          host_name               $host 
  101.          service_description     Nginx-Listener 
  102.          check_command           check_tcp!80 
  103.          max_check_attempts      4 
  104.          normal_check_interval   2 
  105.          retry_check_interval    1 
  106.          check_period            24x7 
  107.          notification_interval   2 
  108.          notification_period     24x7 
  109.          notification_options    w,u,c,r 
  110.          contact_groups          web-server 
  111.          } 
  112.       define service{ 
  113.          host_name               $host 
  114.          service_description     Linux-Memory 
  115.          check_command           check_nrpe!check_mem 
  116.          max_check_attempts      4 
  117.          normal_check_interval   3 
  118.          retry_check_interval    2 
  119.          check_period            24x7 
  120.          notification_interval   10 
  121.          notification_period     24x7 
  122.          notification_options    w,u,c,r 
  123.          contact_groups          web-server 
  124.          } 
  125.       define service{ 
  126.          host_name               $host 
  127.          service_description     Linux-load 
  128.          check_command           check_nrpe!check_load 
  129.          max_check_attempts      4 
  130.          normal_check_interval   3 
  131.          retry_check_interval    2 
  132.          check_period            24x7 
  133.          notification_interval   10 
  134.          notification_period     24x7 
  135.          notification_options    w,u,c,r 
  136.          contact_groups          web-server 
  137.          } 
  138.       define service{ 
  139.          host_name               $host 
  140.          service_description     Linux-total-procs 
  141.          check_command           check_nrpe!check_total_procs 
  142.          max_check_attempts      4 
  143.          normal_check_interval   3 
  144.          retry_check_interval    2 
  145.          check_period            24x7 
  146.          notification_interval   10 
  147.          notification_period     24x7 
  148.          notification_options    w,u,c,r 
  149.          contact_groups          web-server 
  150.          } 
  151.       define service{ 
  152.          host_name               $host 
  153.          service_description     Linux-PHP-procs 
  154.          check_command           check_nrpe!check_php_procs 
  155.          max_check_attempts      4 
  156.          normal_check_interval   3 
  157.          retry_check_interval    2 
  158.          check_period            24x7 
  159.          notification_interval   5 
  160.          notification_period     24x7 
  161.          notification_options    w,u,c,r 
  162.          contact_groups          web-server 
  163.          } 
  164.       define service{ 
  165.          host_name               $host 
  166.          service_description     Linux-CPU 
  167.          check_command           check_nrpe!check_cpu 
  168.          max_check_attempts      4 
  169.          normal_check_interval   3 
  170.          retry_check_interval    2 
  171.          check_period            24x7 
  172.          notification_interval   10 
  173.          notification_period     24x7 
  174.          notification_options    w,u,c,r 
  175. 感谢您对【51运维网 http://www.51ou.com/】的支持,我们为您免费提供《搭建linux监控平台之nagios》技术文章,《搭建linux监控平台之nagios》详细使用和说明,有时《搭建linux监控平台之nagios》可能不完善、敬请谅解!如果《搭建linux监控平台之nagios》有错误请给我们留言,我们将尽快修复文章错误,如果您觉得本站不错,请分享给周围的朋友!谢谢!

顶一下
(0)
0%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
验证码:点击我更换图片