首页域名资讯 正文

zabbix导入/导出配置文件(88)

2025-02-21 3 0条评论

通过导入/导出zabbix配置文件,可以将自己写好的模板等配置在网络上分享,也可以导入网络上分享的配置文件,配置文件有两种格式,分为为xml与json,通过zabbix管理界面可以导出xml,通过zabbix api可以导出json与xml格式配置。

 

可导出的项目

  • host groups (只能通过zabbix api导出)
  • templates (包含所有预其直接关联的items, triggers, graphs, screens, discovery rules和link的template)
  • hosts (包含所有与它直接相关的items, triggers, graphs, discovery rules 和link的template)
  • network maps (包含所有相关图片; map export/import 从Zabbix 1.8.2开始被支持)
  • images
  • screens

导出详细说明

  • 导出为单个文件
  • Host and template从模板中link过来的实体 (items, triggers, graphs, discovery rules)不会导出,通过low-level创建的实体不会导出。但是导如之后,会重新创建link的实体。
  • 与low-level实体相关联的实体不会被导出,例如触发器。
  • web items相关的Triggers and graphs不支持导出

导入详细说明

  • 导如过程中遇到任何错误,都会停止导入
  • 支持导如xml与json格式文件,并且文件名后缀必须为.xml或者.json

XML文件基本格式

1 2 3 4 5 <? xml version = “1.0” encoding = “UTF-8” ?> < zabbix_export >     < version > 2.0 < / version >     < date > 2015 02 09T05 : 58 : 54Z < / date > < / zabbix_export >

xml默认头

1 <? xml version = “1.0” encoding = “UTF-8” ?>

zabbix xml root 元素

1 < zabbix_export >

导出版本

1 < version > 2.0 < / version >

导出日期

1 < date > 2015 02 09T05 : 58 : 54Z < / date >

导出模板

configuration>>templates>>勾选需要导出的模板>>左下角下拉列表选择”Export selected”,点击Go,保存xml即可。

如下是我的一个测试模板内容

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 <? xml version = “1.0” encoding = “UTF-8” ?> < zabbix_export >     < version > 2.0 < / version >     < date > 2015 02 09T07 : 34 : 25Z < / date >     < groups >         < group >             < name > Templates < / name >         < / group >     < / groups >     < templates >         < template >             < template > A_Template_For_Discovery < / template >             < name > A_Template_For_Discovery < / name >             < groups >                 < group >                     < name > Templates < / name >                 < / group >             < / groups >             < applications >                 < application >                     < name > Network < / name >                 < / application >             < / applications >             < items / >             < discovery_rules >                 < discovery_rule >                     < name > PING < / name >                     < type > 0 < / type >                     < snmp_community / >                     < snmp_oid / >                     < key > net . if . icmpping < / key >                     < delay > 30 < / delay >                     < status > 0 < / status >                     < allowed_hosts / >                     < snmpv3_contextname / >                     < snmpv3_securityname / >                     < snmpv3_securitylevel > 0 < / snmpv3_securitylevel >                     < snmpv3_authprotocol > 0 < / snmpv3_authprotocol >                     < snmpv3_authpassphrase / >                     < snmpv3_privprotocol > 0 < / snmpv3_privprotocol >                     < snmpv3_privpassphrase / >                     < delay_flex / >                     < params / >                     < ipmi_sensor / >                     < authtype > 0 < / authtype >                     < username / >                     < password / >                     < publickey / >                     < privatekey / >                     < port / >                     < filter > { #LOC}:^cn|^jp</filter>                     < lifetime > 30 < / lifetime >                     < description / >                     < item_prototypes >                         < item_prototype >                             < name > PING IP $ 1 < / name >                             < type > 3 < / type >                             < snmp_community / >                             < multiplier > 1 < / multiplier >                             < snmp_oid / >                             < key > icmpping [ { #IPADD},4,,,]</key>                             < delay > 30 < / delay >                             < history > 90 < / history >                             < trends > 365 < / trends >                             < status > 0 < / status >                             < value_type > 3 < / value_type >                             < allowed_hosts / >                             < units / >                             < delta > 0 < / delta >                             < snmpv3_contextname / >                             < snmpv3_securityname / >                             < snmpv3_securitylevel > 0 < / snmpv3_securitylevel >                             < snmpv3_authprotocol > 0 < / snmpv3_authprotocol >                             < snmpv3_authpassphrase / >                             < snmpv3_privprotocol > 0 < / snmpv3_privprotocol >                             < snmpv3_privpassphrase / >                             < formula > 1000 < / formula >                             < delay_flex / >                             < params / >                             < ipmi_sensor / >                             < data_type > 0 < / data_type >                             < authtype > 0 < / authtype >                             < username / >                             < password / >                             < publickey / >                             < privatekey / >                             < port / >                             < description / >                             < inventory_link > 0 < / inventory_link >                             < applications >                                 < application >                                     < name > Network < / name >                                 < / application >                             < / applications >                             < valuemap / >                         < / item_prototype >                     < / item_prototypes >                     < trigger_prototypes / >                     < graph_prototypes / >                     < host_prototypes / >                 < / discovery_rule >             < / discovery_rules >             < macros / >             < templates >                 < template >                     < name > Template OS Linux < / name >                 < / template >             < / templates >             < screens / >         < / template >     < / templates > < / zabbix_export >

与模板相关的数据都在xml里,它link的模板”Template OS Linux”并未导出。而是通过如下元素将他关联起来,下回导入还会link一次。

1 2 3 4 5 < templates >     < template >         < name > Template OS Linux < / name >     < / template > < / templates >

通过此方式,大家可以互相共享配置文件,提高效率。

文章转载来自:trustauth.cn

文章版权及转载声明

本文作者:亿网 网址:https://edns.com/ask/post/150575.html 发布于 2025-02-21
文章转载或复制请以超链接形式并注明出处。