codecamp

host管理

主机列表

[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
hostgroup管理
用户管理
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }