码迷,mamicode.com
首页 > Web开发 > 详细

自动化运维工具之Zabbixzabbix发现_自动注册及web页面状态监控(四)

时间:2016-11-03 19:13:56      阅读:432      评论:0      收藏:0      [点我收藏+]

标签:discovery   received   services   network   without   

网络发现(Network Discovery)

**网络发现是zabbix最具有特色的功能之一,它能根据用户实现定义好的规则自动添加监控主机和服务等

-->speed up Zabbix deployment

-->simplify administration

-->use Zabbix in rapidly changing environments without excessive administration


**Zabbix的网络发现功能可基于如下信息进行:

-->IP ranges

-->Availability of external services (FTP,SSH,WEB,POP3,IMAP,TCP,etc)

-->Information received from Zabbix agent

-->Information received from SNMP agent


网络发现:过程阶段

**网络发现通常包含两个阶段: discovery和actions

-->Discovery

*-->Zabbix periodically scans the IP range defined in network discovery reles

*--> Zabbix定期扫描网络发现规则定义的IP地址范围

*-->The frequency of the check is configurable for each rule individually

*每个单独的规则都可配置检查的频率

*-->Each rule has a set of service chekcks defined to be performed for the IP range

*-->每个规则都有一套服务chekcks定义为IP范围内进行

*-->Every check of a service and a host (IP) performed by the network discovery module generates a discovery event.

*-->每一个服务的每一个检查和由网络发现模块执行的主机(IP)生成一个发现事件。


Discovery中的事件:
Service Up
Service Down
Host Up
Host Down
Service Discovered
Service Lost
Host Discovered
Host Lost


Action,网络发现中的事件可以触发action,从而自动执行指定的操作,如:
Sending notifications
Adding/removing hosts
Enabling/disabling hosts
Adding hosts to group
Removing hosts from a group
Linking hosts to/unlinking from a template
Executing remote scripts
-->这些事件的配置还可以基于设备的类型、IP、状态、上线/离线进行配置。


网络发现:接口添加

网络发现中添加主机时会自动创建interface

the services detected

-->例如:如果基于SNMP检测成功,则会创建SNMP接口

如果某服务同时响应给了agent和SNMP,则两种接口都会创建。

如果同一种发现机制(如agent)返回了非唯一数据,则第一个接口被识别为默认,其他的为额外接口。

不同的主机如果返回相同的数据,则第一个主机将被添加,余下的主机会被当做第一个主机的额外接口。


自动注册
Zabbix支持active agent的自动注册(auto-resisitration)功能,通常用于此前故障的agent重新上线的场景,也可基于active agent的自动注册机制添加被动检测,这会通过active agent注册时提供的"ListenIP"和"ListenPort"进行,Server端在收到自动注册请求后以接收到的IP和Port为接口属性。


实现过程如下:

(1)创建模板

技术分享

(2)创建模板item

技术分享

技术分享

技术分享

(3)创建模板触发器trigger

技术分享

(4)创建模板视图Graph

技术分享


(5)创建发现规则

技术分享

(6)创建发现actions事件实现添加主机

技术分享

技术分享

技术分享


(7)定义一个用户和组用于接受通知及消息

技术分享

技术分享

技术分享

技术分享

技术分享

在服务器上创建tom用户:

# useradd tom

(8)定义移除action,只要探测失败,就移除主机:

技术分享

技术分享

技术分享


(9)网络发现:配置active agent自动注册

*-->Configuration-->Actions-->Event source(Autoregistration)-->Create action

技术分享

此外,还需要配置agent的工作属性,并重启agent

-->zabbix-agentd.conf

ServerActive=172.16.100.2

#指向zabbix server

配置如下:

技术分享

技术分享

(10)配置被监控端如下配置:

# cat /etc/zabbix/zabbix_agentd.conf | grep -E ‘(ServerActive|Server|usage)‘
Server=172.16.100.2
ServerActive=172.16.100.2
UserParameter=memory.usage[*],/bin/cat /proc/meminfo | awk ‘/^$1:/{print $$2}‘



配置web页面监控应用

Zabbix还可以进行web站点监控的可用性检测

创建web监控需要先定义一个web方案(scenarios)

-->web方案包括一个或多个HTTP请求或"步骤(step)"

-->步骤(step)的执行过程安装预先定义的顺序进行执行

通过web监控可实时获取如下消息

-->整个web方案中所有的步骤的平均下载速度

-->失败的步骤号

-->失败的报错信息

在web方案的具体步骤中,可以按需要使用如下消息

-->该步骤的下载速度

-->回应时间

-->回应状态码

Zabbix可以检测获取到的HTML页面中是否包含预设的字符串,也可以实现登录和页面点击。


创建web监控方案

**创建web方案的前提需要创建一个适用的应用(application)

可以在"Hosts"或"Templates"上创建应用

如果在"Templates"上创建应用,则需要将此"Templates"链接至要监控的其web的主机上方能使用此"application"


下面创建web监控
首先,在172.16.100.7主机中定义application

技术分享

技术分享

技术分享


Scenario items

方案创建完成后,zabbix将会自动在链接的Application中添加如下监控项

NameKeyTypeType of informationStatus
Download speed for scenario "Web Monitoring".web.test.in[Web Monitoring,,bps]Web monitoringNumeric (float)Enabled
Download speed for step "test" of scenario "Web Monitoring".web.test.in[Web Monitoring,test,bps]Web monitoringNumeric (float)Enabled
Download speed for step "Home" of scenario "Web Monitoring".web.test.in[Web Monitoring,Home,bps]Web monitoringNumeric (float)Enabled
Failed step of scenario "Web Monitoring".web.test.fail[Web Monitoring]Web monitoringNumeric (unsigned)Enabled
Last error message of scenario "Web Monitoring".web.test.error[Web Monitoring]Web monitoringCharacterEnabled

在创建触发器和告警时可以利用这些监控项,例如:

-->{host:web.test.fail[www.samlee.com].last(0)}#0

-->{host:web:test.in[www.samlee.com,,bps].last(0)}<10000


最后查看数据示意图如下:

技术分享

可以看到页面的响应速度和下载速度
创建web监控的trigger,表达式为主页最后一次的响应码不等于200就触发事件:

技术分享

以上为Zabbixzabbix发现_自动注册及web页面状态监控所有内容。

本文出自 “Opensamlee” 博客,请务必保留此出处http://gzsamlee.blog.51cto.com/9976612/1868999

自动化运维工具之Zabbixzabbix发现_自动注册及web页面状态监控(四)

标签:discovery   received   services   network   without   

原文地址:http://gzsamlee.blog.51cto.com/9976612/1868999

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!