2022 Zabbix中国峰会
2022 Zabbix中国峰会

configuration.export

Description

string configuration.export(object parameters)

This method allows to export configuration data as a serialized string.此方法允许作为序列化字符串导出配置数据。

Parameters参数

(object) Parameters defining the objects to be exported and the format to use.参数定义了导出的对象以及使用的格式。

参数 类 说明
format
(required)(必须)
string
Format in which the data must be exported.导出数据的格式。
Possible values: 可能的值为:
json - JSON;
xml - XML.
options
(required) (必须)
object
Objects to be exported. 导出的对象。
The options object has the following parameters:对象有以下参数:
groups - (array) IDs of host groups to export; 主机组ID的导出;
hosts - (array) IDs of hosts to export; 主机ID的导出;
images - (array) IDs of images to export;图表ID的导出;
maps - (array) IDs of maps to export. 拓扑图ID的导出;
screens - (array) IDs of screens to export;屏幕ID的导出;
templates - (array) IDs of templates to export;模板ID的导出;
valueMaps - (array) IDs of value maps to export; 值映射ID的导出;

Return values返回值

(string) Returns a serialized string containing the requested configuration data.返回一个序列化字符串包含请求的配置数据。

Examples 范例

Exporting a host导出一个主机。

Export the configuration of a host as an XML string.导出一个XML字符串的主机配置。

Request:

{
           "jsonrpc": "2.0",
           "method": "configuration.export",
           "params": {
               "options": {
                   "hosts": [
                       "10161"
                   ]
               },
               "format": "xml"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<zabbix_export><version>3.4</version><date>2017-02-13T14:27:34Z</date><groups><group><name>Zabbix servers</name></group></groups><hosts><host><host>Export host</host><name>Export host</name><description/><proxy/><status>0</status><ipmi_authtype>-1</ipmi_authtype><ipmi_privilege>2</ipmi_privilege><ipmi_username/><ipmi_password/><tls_connect>1</tls_connect><tls_accept>1</tls_accept><tls_issuer/><tls_subject/><tls_psk_identity/><tls_psk/><templates/><groups><group><name>Zabbix servers</name></group></groups><interfaces><interface><default>1</default><type>1</type><useip>1</useip><ip>127.0.0.1</ip><dns/><port>10050</port><bulk>1</bulk><interface_ref>if1</interface_ref></interface></interfaces><applications><application><name>Application</name></application></applications><items><item><name>Item</name><type>0</type><snmp_community/><snmp_oid/><key>item.key</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>3</value_type><allowed_hosts/><units/><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>Application</name></application></applications><valuemap><name>Host status</name></valuemap><logtimefmt/><preprocessing/><interface_ref>if1</interface_ref></item></items><discovery_rules/><macros/><inventory/></host></hosts><triggers><trigger><expression>{Export host:item.key.last()}=0</expression><name>Trigger</name><url/><status>0</status><priority>2</priority><description>Host trigger</description><type>0</type><recovery_mode>1</recovery_mode><recovery_expression>{Export host:item.key.last()}=2</recovery_expression><dependencies/><tags/><correlation_mode>1</correlation_mode><correlation_tag>Tag 01</correlation_tag><manual_close>0</manual_close></trigger></triggers><graphs><graph><name>Graph</name><width>900</width><height>200</height><yaxismin>0.0000</yaxismin><yaxismax>100.0000</yaxismax><show_work_period>1</show_work_period><show_triggers>1</show_triggers><type>0</type><show_legend>1</show_legend><show_3d>0</show_3d><percent_left>0.0000</percent_left><percent_right>0.0000</percent_right><ymin_type_1>0</ymin_type_1><ymax_type_1>0</ymax_type_1><ymin_item_1>0</ymin_item_1><ymax_item_1>0</ymax_item_1><graph_items><graph_item><sortorder>0</sortorder><drawtype>0</drawtype><color>C80000</color><yaxisside>0</yaxisside><calc_fnc>7</calc_fnc><type>0</type><item><host>Export host</host><key>item.key</key></item></graph_item></graph_items></graph></graphs><value_maps><value_map><name>Host status</name><mappings><mapping><value>0</value><newvalue>Up</newvalue></mapping><mapping><value>2</value><newvalue>Unreachable</newvalue></mapping></mappings></value_map></value_maps></zabbix_export>\n",
           "id": 1
       }

Source来源

CConfiguration::export() in frontends/php/include/classes/api/services/CConfiguration.php.