linux監控平台nagios的使用(四)監控端添加服務

來源:互聯網
上載者:User

被監控端工作已經做好了,現在就只要在監控端進行操作了;

注意一下:被監控中mysql記得要設密碼啊

添加服務類型也是2種:

1.web伺服器

2.mysql伺服器

下面是添加web服務的指令碼:

webservices () {     read -p " Please input the web server IP: " webip     read -p "please input the web alias name : "  host     echo "define host{             host_name                       $host             alias                           web-server             address                         $webip             check_command                   check-host-alive             max_check_attempts              5             check_period                    24x7             contact_groups                  web-server             notification_interval           10             notification_period             24x7             notification_options            d,u,r             }" >> /usr/local/nagios/etc/objects/hosts.cfg     sed -i "6,10{/members/s/$/,$host/}" /usr/local/nagios/etc/objects/hostgroups.cfg              echo "     define hostescalation{                      host_name               $host                            first_notification      5                                      last_notification       0                                      notification_interval   10                                    contact_groups          web-server                                  }      define serviceescalation{                      host_name               $host                      service_description     Nginx-Listener                            first_notification      5                      last_notification       0                      notification_interval   10                      contact_groups          web-server                      }      define serviceescalation{                      host_name               $host                      service_description     Linux-PHP-procs                            first_notification      5                      last_notification       0                      notification_interval   10                      contact_groups          web-server                      }      define serviceescalation{                      host_name               $host                      service_description     Linux-iftraffic                            first_notification      5                      last_notification       0                      notification_interval   10                      contact_groups          web-server                      }      define serviceescalation{                      host_name               $host                      service_description     check-ips                            first_notification      5                      last_notification       0                      notification_interval   10                      contact_groups          web-server                      } " >> /usr/local/nagios/etc/objects/escalations.cfg               echo "         define service{             host_name               $host             service_description     check-host-alive             check_command           check-host-alive             max_check_attempts      4             normal_check_interval   3             retry_check_interval    2             check_period            24x7             notification_interval   10             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     disk-/             check_command           check_local_disk!10%!5%!/             max_check_attempts      4             normal_check_interval   3             retry_check_interval    2             check_period            24x7             notification_interval   10             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     SSH-Listener             check_command           check_tcp!22             max_check_attempts      4             normal_check_interval   3             retry_check_interval    2             check_period            24x7             notification_interval   10             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     Nginx-Listener             check_command           check_tcp!80             max_check_attempts      4             normal_check_interval   2             retry_check_interval    1             check_period            24x7             notification_interval   2             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     Linux-Memory             check_command           check_nrpe!check_mem             max_check_attempts      4             normal_check_interval   3             retry_check_interval    2             check_period            24x7             notification_interval   10             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     Linux-load             check_command           check_nrpe!check_load             max_check_attempts      4             normal_check_interval   3             retry_check_interval    2             check_period            24x7             notification_interval   10             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     Linux-total-procs             check_command           check_nrpe!check_total_procs             max_check_attempts      4             normal_check_interval   3             retry_check_interval    2             check_period            24x7             notification_interval   10             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     Linux-PHP-procs             check_command           check_nrpe!check_php_procs             max_check_attempts      4             normal_check_interval   3             retry_check_interval    2             check_period            24x7             notification_interval   5             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     Linux-CPU             check_command           check_nrpe!check_cpu             max_check_attempts      4             normal_check_interval   3             retry_check_interval    2             check_period            24x7             notification_interval   10             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     Linux-user             check_command           check_nrpe!check_users             max_check_attempts      4             normal_check_interval   3             retry_check_interval    2             check_period            24x7             notification_interval   10             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     check-ips             check_command           check_nrpe!check_ips             max_check_attempts      4             normal_check_interval   2             retry_check_interval    2             check_period            24x7             notification_interval   8             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }          define service{             host_name               $host             service_description     Linux-iftraffic             check_command           check_nrpe!check_iftraffic!"eth0"!50!100!50!m             max_check_attempts      4             normal_check_interval   4             retry_check_interval    2             check_period            24x7             notification_interval   5             notification_period     24x7             notification_options    w,u,c,r             contact_groups          web-server             }     " >> /usr/local/nagios/etc/objects/services.cfg     echo "###############  Add web-server services completed ########"           }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.