
zabbix agent自动注册
自动注册还是自动发现?自动注册!
修改zabbix_agentd.conf中的ServerActive(主动模式ip)即可
配置自动注册action 文档:Method reference (zabbix.com)
from zabbix_utils import ZabbixAPI # 配置server的url,登录名,密码 api=ZabbixAPI(url='http://192.168.40.10/zabbix/api_jsonrpc.php') api.login(user='Admin', password='zabbix') # 指定api方法 method="action.create" # 传入参数,详见官方文档 params={ "name":"Register Linux servers", "eventsource":2, "filter":{ "evaltype":2, "conditions":[ { "conditiontype":22, "operator":2, "value":"SRV" }, { "conditiontype":24, "operator":2, "value":"CentOS" } ] }, "operations":[ { "operationtype":2 } ] } response=api.send_api_request(method=method, params=params) print(response) api.logout()
如果一个ip上有多个主机,需要为每台主机安装的agent配置metadata,在agent配置文件中有两种方法指定metadata,HostMetadata以及HostMetadataItem如下,配置action中的条件即可
HostMetadataItem=system.uname # 示例: # Linux: Linux server3 3.2.0-4-686-pae #1 SMP Debian 3.2.41-2 i686 GNU/Linux # Windows: Windows WIN-0PXGGSTYNHO 6.0.6001 Windows Server 2008 Service Pack 1 Intel IA-32
自动注册的主机默认加入discovered hosts
注意!Server和SeverActive是分开的两个概念,只不过平常都设为一个值。Server是被动模式所指定的server ip,active是主动模式,要配置监控项时需要区分agent类型!
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 程序员小航
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果