主動注冊(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端的錯誤日志進行定位。