6 Media types

Overview

Media types are exported with all related objects and object relations.

Exporting

To export media types, do the following:

  • Go to: AdministrationMedia types

  • Mark the checkboxes of the media types to export

  • Click on Export below the list

6 Media types - 图1

Selected media types are exported to a local XML file with default name zbx_export_mediatypes.xml.

Importing

To import media types, do the following:

  • Go to: AdministrationMedia types

  • Click on Import to the right

  • Select the import file

  • Mark the required options in import rules

  • Click on Import

6 Media types - 图2

A success or failure message of the import will be displayed in the frontend.

Import rules:

RuleDescription
Update existingExisting elements will be updated with data taken from the import file. Otherwise they will not be updated.
Create newThe import will add new elements using data from the import file. Otherwise it will not add them.
Delete missingThe import will remove existing elements not present in the import file. Otherwise it will not remove them.

Export format

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <zabbix_export>
  3. <version>5.0</version>
  4. <date>2020-01-24T06:44:38Z</date>
  5. <media_types>
  6. <media_type>
  7. <name>Slack chat</name>
  8. <type>WEBHOOK</type>
  9. <parameters>
  10. <parameter>
  11. <name>channel</name>
  12. <value>{ALERT.SENDTO}</value>
  13. </parameter>
  14. <parameter>
  15. <name>text</name>
  16. <value>{ALERT.MESSAGE}</value>
  17. </parameter>
  18. <parameter>
  19. <name>username</name>
  20. <value>bot</value>
  21. </parameter>
  22. </parameters>
  23. <script>var req = new CurlHttpRequest();&#13;
  24. req.AddHeader('Content-Type: application/x-www-form-urlencoded');&#13;
  25. &#13;
  26. Zabbix.Log(127, 'webhook requqest value='+value);&#13;
  27. &#13;
  28. req.Post('https://hooks.slack.com/services/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',&#13;
  29. 'payload='+value&#13;
  30. );&#13;
  31. &#13;
  32. Zabbix.Log(127, 'response code: '+req.Status());&#13;
  33. &#13;
  34. return JSON.stringify({&#13;
  35. 'tags': {&#13;
  36. 'delivered': 'slack'&#13;
  37. }&#13;
  38. });</script>
  39. <process_tags>YES</process_tags>
  40. <show_event_menu>YES</show_event_menu>
  41. <event_menu_url>https://www.zabbix.com</event_menu_url>
  42. <event_menu_name>Slack message</event_menu_name>
  43. <description>Slack chat messages.</description>
  44. </media_type>
  45. </media_types>
  46. </zabbix_export>

Element tags

Element tag values are explained in the table below.

ElementElement propertyRequiredTypeRange1Description
media_types-Root element for media_types.
media_type-Individual media_type.
namexstringMedia type name.
typexstring0 - EMAIL
1 - SMS
2 - SCRIPT
4 - WEBHOOK
Transport used by the media type.
status-string0 - ENABLED (default)
1 - DISABLED
Whether the media type is enabled.
max_sessions-integerPossible values for SMS: 1 - (default)

Possible values for other media types: 0-100, 0 - unlimited
The maximum number of alerts that can be processed in parallel.
attempts-integer1-10 (default: 3)The maximum number of attempts to send an alert.
attempt_interval-string0-60s (default: 10s)The interval between retry attempts.

Accepts seconds and time unit with suffix.
description-stringMedia type description.
message_templates-Root element for media type message templates.
message_template-Individual message template.
event_sourcexstring0 - TRIGGERS
1 - DISCOVERY
2 - AUTOREGISTRATION
3 - INTERNAL
Event source.
operation_modexstring0 - PROBLEM
1 - RECOVERY
2 - UPDATE
Operation mode.
subject-stringMessage subject.
message-stringMessage body.
Used only by e-mail media type
smtp_serverxstringSMTP server.
smtp_port-integerDefault: 25SMTP server port to connect to.
smtp_heloxstringSMTP helo.
smtp_emailxstringEmail address from which notifications will be sent.
smtp_security-string0 - NONE (default)
1 - STARTTLS
2 - SSL_OR_TLS
SMTP connection security level to use.
smtp_verify_host-string0 - NO (default)
1 - YES
SSL verify host for SMTP. Optional if smtp_security is STARTTLS or SSL_OR_TLS.
smtp_verify_peer-string0 - NO (default)
1 - YES
SSL verify peer for SMTP. Optional if smtp_security is STARTTLS or SSL_OR_TLS.
smtp_authentication-string0 - NONE (default)
1 - PASSWORD
SMTP authentication method to use.
username-stringUsername.
password-stringAuthentication password.
content_type-string0 - TEXT
1 - HTML (default)
Message format.
Used only by SMS media type
gsm_modemxstringSerial device name of the GSM modem.
Used only by script media type
script namexstringScript name.
parameters-Root element for script parameters.
parameter-Individual script parameter.
Used only by webhook media type
scriptxstringScript.
timeout-string1-60s (default: 30s)Javascript script HTTP request timeout interval.
process_tags-string0 - NO (default)
1 - YES
Whether to process returned tags.
show_event_menu-string0 - NO (default)
1 - YES
If {EVENT.TAGS.} were successfully resolved in event_menu_url and event_menu_name fields, this field indicates presence of entry in the event menu.
event_menu_url-stringURL of the event menu entry. Supports {EVENT.TAGS.} macro.
event_menu_name-stringName of the event menu entry. Supports {EVENT.TAGS.*} macro.
parameters-Root element for webhook media type parameters.
parameter-Individual webhook media type parameter.
namexstringWebhook parameter name.
value-stringWebhook parameter value.
Footnotes

1 For string values, only the string will be exported (e.g. “EMAIL”) without the numbering used in this table. The numbers for range values (corresponding to the API values) in this table is used for ordering only.