如何实现Zabbix的主动注册功能,实现zabbix


主动注册(Active Agent Auto-Registration),顾名思义,无需在Zabbix Web上手动添加host信息,即可实现主机的监控。

它是由Agent主动向Server注册。

相对于另一项类似功能-网络发现,它无需知道Agent端的IP地址段和操作系统版本信息,使用上更灵活。

 

创建自动注册规则

Configuration -> Actions -> Create action -> Auto registration

 

配置Action

填写Action的名字

 

设置Conditions

其中,New condition有三种类型

1. Host metadata

2. Host name

3. Proxy

Host metadata是Zabbix 2.2新增的功能,在之前的版本中,只有Host name和Proxy两个选项,

其中,Host name判断的是Agent配置文件中Hostname的值。

Proxy需给定proxy的名字。

在实际的生产环境中并不能满足需求,因为有时候服务器的主机名并没有规律,譬如云环境下。

Host metadata给出了这种场景下的解决方案,

它在Agent配置文件中提供了两个配置参数。

HostMetadata和HostMetadataItem

### Option: HostMetadata
#       Optional parameter that defines host metadata.
#       Host metadata is used at host auto-registration process.
#       An agent will issue an error and not start if the value is over limit of 255 characters.
#       If not defined, value will be acquired from HostMetadataItem.
#
# Mandatory: no
# Range: 0-255 characters
# Default:
# HostMetadata=

### Option: HostMetadataItem
#       Optional parameter that defines an item used for getting host metadata.
#       Host metadata is used at host auto-registration process.
#       During an auto-registration request an agent will log a warning message if
#       the value returned by specified item is over limit of 255 characters.
#       This option is only used when HostMetadata is not defined.
#
# Mandatory: no
# Default:
# HostMetadataItem=

其中

HostMetadata是手动指定,用于定义主机的元数据,类似于描述。

譬如 HostMetadata=Linux

HostMetadataItem需填写item,通常设置为system.uname。

system.uanme的返回值如下:

# zabbix_get -s node1 -k system.uname
Linux node1 2.6.32-573.el6.x86_64 #1 SMP Wed Jul 1 18:23:37 EDT 2015 x86_64

 

设置Operations

在这里,可以执行如下操作:

Send message

Remote command

Add  host

Add to host group

Link to template

Disable host

在这里,我设置了如下操作:

Add host,Link to template,Send message

 

修改zabbix客户端配置文件

[root@node2 ~]# vim /etc/zabbix/zabbix_agentd.conf

主要是配置如下两个选项

ServerActive=192.168.244.30
HostMetadataItem=system.uname

 

启动zabbix客户端

[root@node2 ~]# service zabbix-agent start

验证node2是否自动注册成功

1. 最直观的是查看Configuration -> Hosts

如图所示,node2已添加成功。

 

2. 因为我之前设置Operations的时候,添加了Send message操作(类似于利用脚本实现告警),所以可通过Administration -> Audit -> Actions查看主机是否自动注册成功。

 

3. 如果没有添加成功,可根据Zabbix Server端和Agent端的错误日志进行定位。

 

相关内容

    暂无相关文章