Zabbix Documentation 1.8

1.8
  2.0  2.2  2.4  3.0  3.2  3.4

User Tools

Site Tools


Sidebar

manual:xml_export_import

6 XML Import and Export

1 Goals

Zabbix Import/Export functionality is created to make possible effective exchange of various configuration entities.

Data is exported in XML format which is easy to read and modify.

Use cases:

  • Sharing of templates or network maps

Zabbix users may share configuration parameters.

  • Integration with third-party tools

Universal XML format makes integration and data import/export possible with third party tools and applications.

Exporting and importing network maps is supported since Zabbix version 1.8.2.

2009/08/13 08:03 · richlv

2 Overview

Currently two main categories of configuration are supported for export - hosts and their associated data, and network maps.

2.1 Host import/export

Zabbix host import/export processes the following data:

  • Hosts and their linkage to templates;
  • Templates;
  • Applications;
  • Items;
  • Triggers;
  • Custom graphs;
  • User macros.

2.2 Map import/export

Zabbix map import/export supports the following elements since version 1.8.2:

  • Full map configuration;
  • All map elements, including images, triggers, hosts, host groups and maps;
  • All connectors with associated data, including labels and status indicators.

Additionally, since 1.8.3 used images (icons and background images) are exported as well.

2.3 Screen import/export

Zabbix screen import/export supports all screen elements.

2009/08/13 08:08 · richlv

3 Host export

For Zabbix versions up to 1.8.3, host and template export is available at Configuration → Export/Import. Starting with 1.8.3, import and export controls are available on corresponding configuration pages (Configuration → Hosts and Configuration → Templates).

3.1 Since Zabbix 1.8.3

3.1.1 Step 1

Navigate either to Configuration → Hosts or Configuration → Templates, depending on which ones you want to export. Mark checkboxes next to elements to be exported.

3.1.2 Step 2

Make sure that Export selected is chosen in the activity dropdown below host or template list, then click Go and save the file.

3.2 Up to Zabbix 1.8.3

Step 1

Select elements for export

We selected host “Template_Linux” and all its items and triggers.

Press button “Preview” to see list of elements to be exported:

Step 2

Export data

Press button “Export” to export selected elements to a local XML file with default name zabbix_export.xml. The file has the following format (one element of each type is shown):

<?xml version="1.0"?>
<zabbix_export version="1.0" date="11.05.07" time="11.11">
	<hosts>
		<host name="ZABBIX Server">
			<useip>1</useip>
			<ip>127.0.0.1</ip>
			<port>10050</port>
			<status>1</status>
			<groups>
			</groups>
			<items>
				<item type="0" key="agent.ping" value_type="3">
					<description>Ping to the server (TCP)</description>
					<delay>30</delay>
					<history>7</history>
					<trends>365</trends>
					<snmp_port>161</snmp_port>
					<valuemap>Service state</valuemap>
					<applications>
						<application>General</application>
					</applications>
				</item>
                  ....
			</items>
			<triggers>
				<trigger>
					<description>Version of zabbix_agent(d) was changed on {HOSTNAME}</description>
					<expression>{{HOSTNAME}:agent.version.diff(0)}&gt;0</expression>
					<priority>3</priority>
				</trigger>
                  ....
			<graphs>
				<graph name="CPU Loads" width="900" height="200">
					<show_work_period>1</show_work_period>
					<show_triggers>1</show_triggers>
					<yaxismin>0.0000</yaxismin>
					<yaxismax>100.0000</yaxismax>
					<graph_elements>
						<graph_element item="{HOSTNAME}:system.cpu.load[,avg15]">
							<color>990000</color>
							<yaxisside>1</yaxisside>
							<calc_fnc>2</calc_fnc>
							<periods_cnt>5</periods_cnt>
						</graph_element>
						<graph_element item="{HOSTNAME}:system.cpu.load[,avg1]">
							<color>009900</color>
							<yaxisside>1</yaxisside>
							<calc_fnc>2</calc_fnc>
							<periods_cnt>5</periods_cnt>
						</graph_element>
						<graph_element item="{HOSTNAME}:system.cpu.load[,avg5]">
							<color>999900</color>
							<yaxisside>1</yaxisside>
							<calc_fnc>2</calc_fnc>
							<periods_cnt>5</periods_cnt>
						</graph_element>
					</graph_elements>
				</graph>
                  ....
			</graphs>
		</host>
                  ....
	</hosts>
</zabbix_export>
2009/08/13 08:08 · richlv

4 Host import

For Zabbix versions up to 1.8.3, host and template import is available at Configuration → Export/Import. Starting with 1.8.3, import and export controls are available on corresponding configuration pages (Configuration → Hosts and Configuration → Templates).

Step 1

Configure settings for data import and press “Import”.

Pay attention to the following parameters of the item:

PARAMETERDescription
Import fileFile name of XML file.
RulesElement defines element of XML file.
If parameter Update is set for Existing element, then the import will update it with data taken from the file. Otherwise it will not update it.
If parameter Add is set for Missing element, then the import will add new element with data taken from the file. Otherwise it will not add it.

Note that Zabbix versions 1.8.x place triggers before items in the export and such data can not be imported in Zabbix 1.6.x. If such a path is desired, items should be moved in front of the triggers.

2009/08/13 08:58 · richlv

5 Map export and import

Map export and import is available since Zabbix version 1.8.2.

Map export and import controls can be found under Configuration → Maps menu, where all configured maps are displayed.

5.1 Map exporting

In left bottom corner a selection box is available with two options: “Export selected” and “Delete selected”. To export maps:

  1. Mark boxes next to maps you wish to export;
  2. Select “Export selected” if it's not selected already;
  3. Press button “Go”;
  4. Select file where Zabbix should store XML data with exported maps.

5.2 Map importing

Importing maps is as easy as exporting them. On the top right corner near “Create Map” button, you will find new button - “Import Map”.

To import maps:

  1. Press “Import Map” button. You will get to a screen similar to what you see when importing hosts in Configuration→ Export/Import (Import) menu;
  2. Press on “Choose file” button to select XML file containing exported Zabbix maps;
  3. Check box under “Update existing” if you need to update (overwrite) existing maps;
  4. Check box under “Add missing” if you need to create a new map if it's missing;
  5. Press import to send needed data to Zabbix frontend;
  6. Wait till page reloads. It can take some time if you have lots of maps to import or lots of hosts, triggers etc. Zabbix frontend will inform you about import success or failure.
Map import dialogueMap import dialogue for Zabbix super admin, showing image importing options (available since version 1.8.3)

Click on “Details” link on the left hand side to see more information about what was done by import, or why it failed to import.

5.3 What is exported?

Only map structure is exported. That means all map settings are exported, all contained elements with their settings are exported, so are the map links and map link status indicators.

5.4 What is not exported?

Any maps, hostgroups, hosts, triggers, images or any others elements related to the exported map are not exported. Thus if at least one of the elements map refers to is missing, import will fail.

For example, if map refers to a specific trigger on a specific node, but this trigger has been deleted in the meantime, import would fail with an error message:

Cannot find trigger "our_node5:Zabbix server:Disk is full" used in exported map "Small map".

5.5 Export format

An example empty map export with background image from a distributed setup node:

 <sysmap>
   <selements>
   </selements>
   <links>
   </links>
   <name>TEST</name>
   <width>800</width>
   <height>600</height>
   <backgroundid>
     <node>aly_trunk</node>
     <name>Map BG</name>
   </backgroundid>
   <label_type>2</label_type>
   <label_location>0</label_location>
   <highlight>1</highlight>
   <expandproblem>1</expandproblem>
 </sysmap>
5.5.1 Map elements

Let's take XML excerpt of some Zabbix map element as an example:

     <selement>
       <selementid>100100000000372</selementid>
       <elementid>
         <node>noden1</node>
         <host>LocalHost</host>
         <description>DOUBLE</description>
         <expression>{TimeHost:system.localtime[local].last(0)}=0 &amp; {TimeHost:system.localtime[local].last(0)}=2</expression>
       </elementid>
       <elementtype>2</elementtype>
       <iconid_off>
         <node>noden1</node>
         <name>Hub</name>
       </iconid_off>
       <label>New Element</label>
       <label_location>-1</label_location>
       <x>231</x>
       <y>122</y>
     </selement>
  • <selement> is the opening tag for an element (shorthand of “System map element”);
  • <selementid> is a unique element id, used for map link references;
  • <elementid> refers to the actual Zabbix entity that is represented on the map (map/hostgroup/host etc.;
  • <node> tag will be present if the exported map comes from a distributed setup, skipped otherwise;
  • <elementtype> describes what type of element info is stored in <elementid> node;

When importing an XML, selementid values don't have to match any values in the existing dataset - they are only used to determine map link connections.

5.5.2 Element types and storage

elementtype tag in map export can be one of the following:

ValueType
0Host
1Map
2Trigger
3Host group
4Image
  • Host reference

DM (distributed monitoring) setup

       <node>noden1</node>
       <host>LocalHost</host>

Single server setup

       <host>LocalHost</host>

Hosts are referred to by host name.

  • Map reference

DM setup

       <node>noden1</node>
       <name>Local map</name>

Single server setup

       <name>Local map</name>

Maps are referred to by map name.

  • Trigger reference

Triggers are described in a more complex way:

DM setup

       <node>noden1</node>
       <host>LocalHost</host>
       <description>Lack of free memory on server {HOSTNAME}</description>
       <expression>{LocalHost:vm.memory.size[free].last(0)}&lt;10000</expression>

Single server setup

       <host>LocalHost</host>
       <description>Lack of free memory on server {HOSTNAME}</description>
       <expression>{LocalHost:vm.memory.size[free].last(0)}&lt;10000</expression>

Trigger is referred to by host name, trigger description and trigger expression.

  • Host group reference

DM setup

       <node>noden1</node>
       <name>Local Host Group</name>

Single server setup

       <name>Local Host Group</name>

Host groups are referred to by host group name.

  • Image reference

For images <elementid> node can be skipped.

Nodes <iconid_off>, <iconid_on>, <iconid_unknown>, <iconid_maintenance> and <iconid_disabled> describes what icons should be used for the map element according to its status.

For default icon, <iconid_off> is used.

Inside icon block, image itself is specified: DM setup

       <node>noden1</node>
       <name>Local Image</name>

Single server setup

       <name>Local Image</name>

To use default icon for any state, node for that state should be skipped in the <selement> block.

5.5.3 Element labels
  • <label> describes map elements labels. Macros can be used in labels.
  • <label_location> is used for positioning element's label:
ValueType
-1use map default
0bottom
1left
2right
3top
5.5.4 Element positioning

<x> and <y> nodes are used for positioning element on the map by x and y coordinates.

Example:

     <link>
       <selementid1>100100000000399</selementid1>
       <selementid2>100100000000402</selementid2>
       <drawtype>0</drawtype>
       <color>00AA00</color>
       <linktriggers>
       </linktriggers>
     </link>
  • <selemetid1> and <selementid2> nodes are used to specify map elements that link connects.
  • <drawtype> defines default link style:
ValueStyle
0line
2bold line
3dot
4dashed line
  • <color> specifies what the default link colour is;
  • <linktriggers> contains information about link status indicators.

Example:

         <linktrigger>
           <triggerid>
             <node>aly_trunk</node>
             <host>Symmetra PX40 Clone2</host>
             <description>APC: Input Current (PHASE L3)</description>
             <expression>{Symmetra PX40 Clone2:upsPhaseInputCurrent.L3.last(0)}&lt;15 | {Symmetra PX40 Clone2:upsPhaseInputCurrent.L3.last(0)}&gt;18</expression>
           </triggerid>
           <drawtype>0</drawtype>
           <color>0</color>
         </linktrigger>
  • <triggerid> describes trigger used for indicating link status. Linked trigger referenced the same as map element trigger;
  • <drawtype> and <color> are used to indicate how link should be drawn on the map if this trigger has the highest severity from all the active triggers that are attached to this link.
5.5.6 Images

Image import/export is supported since Zabbix version 1.8.3.

It is possible to export and import used images alongside maps. If exported map is using any images, they are stored in the resulting XML file. An example of how an exported image might look like:

<images>
  <image>
    <name>Server (small)</name>
    <imagetype>1</imagetype>
    <encodedImage>iVBORw0KGgoAA...ErkJggg==</encodedImage>
  </image>
</images>

Value for the <encodedImage> tag is truncated in the above example.

Used tags:

  • <images> - root element for images
  • <image> - individual image element
  • <name> - image name, unique
  • <imagetype> - image type, where 1 ⇒ icon, 2 ⇒ background
  • <encodedImage> - base64 encoded image

When importing, missing images can be added and existing images can be overwritten by marking appropriate checkboxes. Image importing is only available to users of Zabbix Super Admin type.

Warning: if replacing an existing image, it will affect all maps that are using this image.

It is possible to import images only by unchecking both map checkboxes.

2010/02/22 02:14 · richlv

6 Screen export and import

Screen export and import is available since Zabbix version 1.8.2.

Screen export and import controls can be found under Configuration → Screens menu, where all configured screens are displayed.

6.1 Screen exporting

In left bottom corner a selection box is available with two options: “Export selected” and “Delete selected”.

To export screens:

  1. Mark checkboxes next to screens you wish to export;
  2. Select “Export selected” if it's not selected already;
  3. Press button “Go”;
  4. Select file where Zabbix should store XML data with exported screens.

6.2 Screen importing

Importing screens is as easy as exporting them. On the top right corner near “Create Screen” button, you will find new button - “Import Screen”.

To import screens:

  1. Press “Import Screen” button. File selection along with options to control import is shown;
  2. Click the button to select XML file containing exported Zabbix screens;
  3. Check box under “Update existing” if you need to update (overwrite) existing screens;
  4. Check box under “Add missing” if you need to create new screen if it's missing;
  5. Press import to send needed data to the Zabbix frontend;
  6. Wait till page reloads. It can take some time if you have lots of screens to import or lots their elements. Zabbix frontend will inform you about import success or failure. Click on “Details” link in the left upper corner to see more detailed information about what has been done by import, or why it failed to import.
Screen import form

6.3 Exported data

Only screen structure is exported. That includes all screen settings are and all screen elements along with their configuration.

6.4 Not exported data

Anything included in the screen itself (like a host, hostgroup or any other data) is not exported.

When importing a screen, if any of the referenced elements is missing, import will fail, for example, with:

Cannot find trigger "child_node5: ZBXHost:DOUBLE CHECK" used in exported screen "Link Screen"

6.5 XML format - screen definition

Screen export consists of screen definition itself and any additional elements.

<screens>
  <screen>
    <name>Screen name</name>
    <hsize>1</hsize>
    <vsize>2</vsize>
    <screenitems>
      <screenitem></screenitem>
      ...
      <screenitem></screenitem>
    </screenitems>
  </screen>
</screens>
  • name - screen name;
  • hsize - rows;
  • vsize - columns;
  • screenitem - individual screen items, described below.

6.6 XML format - screen elements

6.7 XML format - available element tags

Bold text - mandatory tag for all elements;
Normal text - tag available for all elements;
Italic text - tag optionally available for some elements (see below for details).

  • <resourcetype> - identifies element type, as per the table above;
  • <resourceid> - identifies resource, if applicable; depends of resource type;
  • <width> - element's width in pixels, if applicable;
  • <height> - element's height in pixels, if applicable;
  • <x> - element location on screen table by X axis (cell of the upper left corner);
  • <y> - element location on screen table by Y axis (cell of the upper left corner);
  • <colspan> - if higher than 1, sets count of columns to merge (to the right);
  • <rowspan> - if higher than 1, sets count of rows to merge (down);
  • <elements> - amount of rows to show, if applicable;
  • <valign> - vertical align: 0 - middle, 1 - top, 2 - bottom;
  • <halign> - horizontal align: 0 - centre, 1 - left, 2 - right;
  • <style> - meaning depends on resource type;
  • <dynamic> - allows to apply the element to different hostgroups and/or hosts, if applicable.

If <resourceid> refers to an object by name, it can have subtags. If data is exported from a distributed setup installation, node will always be identified by name:

<node>Zabbix node</node>

For example, Simple graph <resourceid> entry from a non-distributed setup would look like this:

<resourceid>
  <host>Zabbix server</host>
  <key_>system.cpu.load</key_>
</resourceid>

In a distributed setup, it becomes:

<resourceid>
  <node>Zabbix node</node>
  <host>Zabbix server</host>
  <key_>system.cpu.load</key_>
</resourceid>

Individual object references are listed at each element.

6.8 XML format - individual screen element details, A-Z

Each individual element must have mandatory tags from the previous section and may have tags that are available for all elements. If there are additional tags available for the specific element, they are listed here.

6.8.1 Clock

Resource type 7. Additional tags:

  • <width>;
  • <height>;
  • <style> - Local time (0), Server time (1).
6.8.2 Data overview

Resource type 10. Additional tags:

  • <resourceid> - Host group (by name);
  • <width>;
  • <height>.

Available <resourceid> contents:

<name>Linux servers</name>
6.8.3 Graph

Resource type 0. Additional tags:

  • <resourceid> - Graph (by name);
  • <dynamic>.

Available <resourceid> contents:

<host>Zabbix host</host>
<name>Graph name</name>
6.8.4 History of actions

Resource type 12. Additional tags:

  • <elements> - amount of rows to show.
6.8.5 History of events

Resource type 13. Additional tags:

  • <elements> - amount of rows to show.
6.8.6 Hosts info

Resource type 4. Additional tags:

  • <resourceid> - Host group (by name).

Available <resourceid> contents:

<name>Linux servers</name>
6.8.7 Map

Resource type 2. Additional tags:

  • <resourceid> - Zabbix map (by name).

Available <resourceid> contents:

<name>City map</name>
6.8.8 Plain text

Resource type 3. Additional tags:

  • <resourceid> - Item (by key);
  • <elements> - number of rows to show;
  • <style> - if set, HTML code will rendered for in item data that contains strings;
  • <dynamic>.

Available <resourceid> contents:

<host>Zabbix server</host>
<key_>system.cpu.load</key_>
6.8.9 Screen

Resource type 8. Additional tags:

  • <resourceid> - Screen (by name);

Available <resourceid> contents:

<name>Application servers screen</name>
6.8.10 Server info

Resource type 6. No additional tags available.

6.8.11 Simple graph

Resource type 1. Additional tags:

  • <resourceid> - Item (by key);
  • <dynamic>.

Available <resourceid> contents:

<host>Zabbix server</host>
<key_>system.cpu.load</key_>
6.8.12 Status of host triggers

Resource type 16. Additional tags:

  • <resourceid> - Host (by name);
  • <elements> - number of rows to show.

Available <resourceid> contents:

<host>aleksei_host</host>
6.8.13 Status of hostgroup triggers

Resource type 14. Additional tags:

  • <resourceid> - Host group (by name);
  • <elements> - number of rows to show.

Available <resourceid> contents:

<name>aaa</name>
6.8.14 System status

Resource type 15. No additional tags available.

6.8.15 Triggers info

Resource type 5. Additional tags:

  • <resourceid> - Host group (by name);

Available <resourceid> contents:

<name>aaa</name>
6.8.16 Triggers overview

Resource type 9. Additional tags:

  • <resourceid> - Host group (by name);

Available <resourceid> contents:

<name>aaa</name>
6.8.17 URL

Resource type 11. Additional tags:

  • <url> - fully qualified or relative URL.

6.9 XML export example

The following is a simple screen (2×2), exported to XML. It contains one custom graph in upper left cell (spanning two columns), one simple graph in the lower left cell and trigger status element, filtered for a hostgroup, in the lower right cell. Notice the encoding of & as &amp;.

<?xml version="1.0" encoding="UTF-8"?>
<screens>
  <screen>
    <name>Excellent screen</name>
    <hsize>2</hsize>
    <vsize>2</vsize>
    <screenitems>
      <screenitem>
        <resourcetype>0</resourcetype>
        <resourceid>
          <host>Zabbix server</host>
          <name>CPU Load &amp; traffic</name>
        </resourceid>
        <width>1000</width>
        <height>100</height>
        <x>0</x>
        <y>0</y>
        <colspan>2</colspan>
        <rowspan>0</rowspan>
        <elements>0</elements>
        <valign>0</valign>
        <halign>0</halign>
        <style>0</style>
        <dynamic>0</dynamic>
      </screenitem>
      <screenitem>
        <resourcetype>1</resourcetype>
        <resourceid>
          <host>Zabbix server</host>
          <key_>zabbix[uptime]</key_>
        </resourceid>
        <width>500</width>
        <height>90</height>
        <x>0</x>
        <y>1</y>
        <colspan>0</colspan>
        <rowspan>0</rowspan>
        <elements>0</elements>
        <valign>0</valign>
        <halign>0</halign>
        <style>0</style>
        <dynamic>0</dynamic>
      </screenitem>
      <screenitem>
        <resourcetype>14</resourcetype>
        <resourceid>
          <name>Linux servers</name>
        </resourceid>
        <width>500</width>
        <height>100</height>
        <x>1</x>
        <y>1</y>
        <colspan>0</colspan>
        <rowspan>0</rowspan>
        <elements>25</elements>
        <valign>0</valign>
        <halign>0</halign>
        <style>0</style>
        <dynamic>0</dynamic>
      </screenitem>
    </screenitems>
  </screen>
</screens>
2010/03/16 10:57 · richlv