网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Nagios使用技巧

Nagios 使用技巧

创新互联建站主要业务有网站营销策划、网站制作、成都网站制作、微信公众号开发、微信小程序定制开发H5网站设计、程序开发等业务。一次合作终身朋友,是我们奉行的宗旨;我们不仅仅把客户当客户,还把客户视为我们的合作伙伴,在开展业务的过程中,公司还积累了丰富的行业经验、网络营销推广资源和合作伙伴关系资源,并逐渐建立起规范的客户服务和保障体系。 

需求1.Nagios针对一台主机上的多个域名进行监控

Solution:

使用 check_http插件对站点的状态码进行检测

vim command.cfg

define command{

command_name check_http

command_line $USER1$/check_http -I $ARG1$ -u $ARG2$ -e $ARG3$

}

vim services.cfg

define service{

host_name Web103

service_description check-Web103

max_check_attempts 5

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 admins

check_command check_http!10.100.100.103!http://www.pongo.cn/check/check.html!"200"

}

参数解释:

-I Ipaddress

-u uri

-e 状态码

需求2:Nagios设置报警间隔和报警次数

solution:

注:本次演示主机的,服务的也一样

1.定义从第1次到第5次通知的时间间隔为10分钟

define host {

host_name Web103

alias Web103

address 10.100.100.103

check_command check-host-alive

notification_options d,u,r

check_interval 1

max_check_attempts 2

first_notification 1

last_notification 5

contact_groups admins

notification_interval 10

notification_period 24x7

}

2.从第5次到第10次通知的间隔为30分钟

define host {

host_name Web103

alias Web103

address 10.100.100.103

check_command check-host-alive

notification_options d,u,r

check_interval 1

max_check_attempts 2

first_notification 5

last_notification 10

contact_groups admins

notification_interval 30

notification_period 24x7

}

3.从第10次以后不能通告,直到恢复

define host {

host_name Web103

alias Web103

address 10.100.100.103

check_command check-host-alive

notification_options d,u,r

check_interval 1

max_check_attempts 2

first_notification 10

last_notification 0

contact_groups admins

notification_interval 0

notification_period 24x7

}

注:每次通知都可以设置不同的身份人。

需求3:定义常用服务和主机模板

solution:

将每个服务常用的一些策略和选项放在一起,在每个服务中使用use 应用

define service {

name Web

contact_groups admins

check_period 24x7

normal_check_interval 3

retry_check_interval 2

notification_interval 10

max_check_attempts 5

notification_period 24x7

notification_options w,u,c,r

}

define service {

use Web

host_name Web103

service_description WebSite_hire.pongo.cn

check_command check_web!10.100.100.103!http://hire.pongo.cn/check/check.html!"200"

}

注:由上面可以看出,定义服务时省去了很多选项,使代码看起来越简练,主机的模板和服务的定义类似。

需求4.使用nagios的声音功能,及时了解主机或服务的状态

solution:

# Note: All audio files must be placed in the /media subdirectory

# under the HTML path (i.e. /usr/local/nagios/share/media/).

host_unreachable_sound=hostdown.wav

host_down_sound=hostdown.wav

service_critical_sound=critical.wav

service_warning_sound=warning.wav

service_unknown_sound=warning.wav

normal_sound=noproblem.wav

将声音文件放到/usr/local/nagios/share/media/即可(根据你的安装路径来定),当服务或主机触发不同级别的时候,就会发出不同的声音。

需求5:服务器数量众多,我想为同类型的服务器,主机或服务配置文件放到一个文件中。

solution:

为不同应用类型创建目录和文件

#cd /usr/local/nagios/etc/objects

#mkdir MySQL web *** switch

#cd web

#touch services.cfg host.cfg

#vim /usr/local/nagios/etc/nagios.cfg

cfg_dir=/usr/local/nagios/etc/objects/web

cfg_file=/usr/local/nagios/etc/objects/web/host.cfg

cfg_file=/usr/local/nagios/etc/objects/web/services.cfg

注:其它应用类型和上面添加方法相同。


网页名称:Nagios使用技巧
文章出自:http://bjjierui.cn/article/gsiogs.html

其他资讯