host管理

2018-01-04 16:43 更新

主机列表

[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

创建主机(可设置自动创建,故不常用)

场景:创建主机
操作说明:zabbix_api host_create 主机IP 主机名 主机组名 需要链接的模板名
[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"}

删除主机

场景:删除不需要的主机
操作说明:zabbix_api host_delete 主机名 
[root@Linux ~]#zabbix_api host_delete ceshi_host14
1.2.2
{"status": "OK", "output": "delete host:[ceshi_host14] id:[10109] OK

批量对主机进行 clear 指定模板

场景:某个模板需要clear时
操作说明:zabbix_api hosts_template_clear 模板名
注:可以使用--hostgroupid,--hostid两个选项进行对特定主机或者主机组进行 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

批量对主机进行 link 指定模板

场景:批量对主机进行link指定模板
操作说明:zabbix_api hosts_template_link 模板名

[root@Linux ~]#zabbix_api hosts_template_link "Template OS Linux"
注:可以使用--hostgroupid,--hostid两个选项进行对特定主机或者主机组进行 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
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号