主機(jī)列表
[root@Linux ~]# zabbix_api host_get --table
1.2.1
+--------+----------+----------------+--------+-----------+----------------------------+
| HostID | HostName | ip | Status | Available | templates |
+--------+----------+----------------+--------+-----------+----------------------------+
| 10084 | ceshi | 192.168.31.61 | OK | available | Template App MySQL |
| | | | | | Template App Zabbix Server |
| | | | | | Template OS Linux |
| | | | | | |
| 10105 | Linux | 192.168.31.187 | OK | available | Template App MySQL |
| | | | | | Template OS Linux |
| | | | | | |
+--------+----------+----------------+--------+-----------+----------------------------+
sum: 2
創(chuàng)建主機(jī)(可設(shè)置自動(dòng)創(chuàng)建,故不常用)
場(chǎng)景:創(chuàng)建主機(jī)
操作說明:zabbix_api host_create 主機(jī)IP 主機(jī)名 主機(jī)組名 需要鏈接的模板名
[root@Linux ~]#zabbix_api host_create 192.168.199.5 "ceshi_host5" "store" "Template OS Linux"
1.2.1
{"status": "OK", "output": "create host:[ceshi_host5] hostid:[10111] OK"}
刪除主機(jī)
場(chǎng)景:刪除不需要的主機(jī)
操作說明:zabbix_api host_delete 主機(jī)名
[root@Linux ~]#zabbix_api host_delete ceshi_host14
1.2.2
{"status": "OK", "output": "delete host:[ceshi_host14] id:[10109] OK
批量對(duì)主機(jī)進(jìn)行 clear 指定模板
場(chǎng)景:某個(gè)模板需要clear時(shí)
操作說明:zabbix_api hosts_template_clear 模板名
注:可以使用--hostgroupid,--hostid兩個(gè)選項(xiàng)進(jìn)行對(duì)特定主機(jī)或者主機(jī)組進(jìn)行 clear 模板操作
[root@Linux ~]#zabbix_api hosts_template_clear "Template OS Linux"
[root@Linux zabbix_api]# zabbix_api hosts_template_clear "Template OS Linux" --hostid 10106
1.2.1
clear template [Template OS Linux]...
host:[ceshi_host] ip:[192.168.199.2] OK
批量對(duì)主機(jī)進(jìn)行 link 指定模板
場(chǎng)景:批量對(duì)主機(jī)進(jìn)行l(wèi)ink指定模板
操作說明:zabbix_api hosts_template_link 模板名
[root@Linux ~]#zabbix_api hosts_template_link "Template OS Linux"
注:可以使用--hostgroupid,--hostid兩個(gè)選項(xiàng)進(jìn)行對(duì)特定主機(jī)或者主機(jī)組進(jìn)行 clear 模板操作
[root@Linux zabbix_api]# zabbix_api hosts_template_link "Template OS Linux" --hostid 10106
1.2.1
link template [Template OS Linux]...
host:[ceshi_host] ip:[192.168.199.2] OK
更多建議: