您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
被监控端工作已经做好了,现在就只要在监控端进行操作了;
注意一下:被监控中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 ########"
- }
下面是添加mysql服务的脚本:
- addmysqlservicemaster () {
- read -p " Please input the nagios server IP: " naigosip
- read -p " Please input the mysql server IP: " mysqlip
- read -p " please input the mysql alias name : " host
- read -p " please input the mysql password :" mysqlpwd
- read -p " please input the nagios for mysql's password:" nagiospwd
- echo "define host{
- host_name $host
- alias web-server
- address $mysqlip
- 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 "11,15{/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 mysql-server
- }
- define serviceescalation{
- host_name $host
- service_description Mysql-Listener
- first_notification 5
- last_notification 0
- notification_interval 10
- contact_groups mysql-server
- }
- define serviceescalation{
- host_name $host
- service_description Mysql-Status
- first_notification 5
- last_notification 0
- notification_interval 10
- contact_groups mysql-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 mysql-server
- }
- define service{
- host_name $host
- service_description check_disk
- check_command check_nrpe!check_disk
- 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 mysql-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 mysql-server
- }
- define service {
- host_name $host
- service_description Mysql-Listener
- check_command check_tcp!3306
- 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 mysql-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 mysql-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 mysql-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 mysql-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 mysql-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 mysql-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 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 threads-connected
- check_command check_mysql_health!nagios!$nagiospwd!threads-connected!$mysqlip!3306!
- max_check_attempts 4
- normal_check_interval 2
- retry_check_interval 1
- check_period 24x7
- notification_interval 10
- notification_period 24x7
- notification_options w,u,c,r
- contact_groups mysql-server
- }
- define service{
- host_name $host
- service_description Mysql-Status
- check_command check_mysql
- 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 mysql-server
- } " >> /usr/local/nagios/etc/objects/services.cfg
- echo "###############add mysql services ################"
这样就行了
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。