一起搭建linux监控平台之nagios(五)使用以及相关说明

 使用及相关如下:

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

 

  
  
  
  
  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.   
  28.   
  29.  actionserver () { 
  30.  echo "this is at nagios server:you can change install environment or add services" 
  31.  echo "1,Install  environment  for nagios;" 
  32.  echo "2,add the client services!!!!!!!!!" 
  33.  read aaa 
  34.  case $aaa in 1) 
  35.  installserver  
  36.  addnagios ;; 
  37.  2) 
  38.  addservices ;; 
  39.  *) 
  40.  echo "this is error,please change again." 
  41.  actionserver ;; 
  42.  esac 
  43.  } 
  44.   
  45.  actionclient () { 
  46.  echo "this is at nagios client:you can install the different environment" 
  47.  echo "1,install the environment for web-server!!" 
  48.  echo "2,install the environment for mysql-server" 
  49.  read bbb 
  50.  case $bbb in 1) 
  51.  installweb ;; 
  52.  2) 
  53.  installmysql ;; 
  54.  3) 
  55.  echo "this is error,please change again" 
  56.  actionclient ;; 
  57.  esac 
  58.  } 
  59.   
  60.  echo "######################################" 
  61.  echo "######**this is nagios scripts**######" 
  62.  echo "you can change this action:" 
  63.  echo "1,if you at the nagios server,please check it out!!" 
  64.  echo "2,if you at the nagios client,please check it out!!" 
  65.  read asd 
  66.  case $asd in 1) 
  67.   actionserver ;; 
  68.  2) 
  69.   actionclient ;; 
  70.  *) 
  71.    exit ;; 
  72.  esac 
  73.   

解压完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    
  24.   

 

这可以通过创建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)地址如下:

http://down.51cto.com/data/596794

你可能感兴趣的:(linux,shell,lamp,nagios)