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

Depending on the selected format, media types are exported to a local file with a default name:

  • zabbix_export_mediatypes.yaml - in YAML export (default option for export)

  • zabbix_export_mediatypes.xml - in XML export

  • zabbix_export_mediatypes.json - in JSON export

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

Export to YAML:

  1. ---
  2. zabbix_export:
  3. version: "5.2"
  4. date: "2020-08-06T08:19:30Z"
  5. media_types:
  6. - name: Pushover
  7. type: WEBHOOK
  8. parameters:
  9. 7:
  10. name: eventid
  11. value: '{EVENT.ID}'
  12. 2:
  13. name: message
  14. value: '{ALERT.MESSAGE}'
  15. 6:
  16. name: priority
  17. value: "0"
  18. 3:
  19. name: title
  20. value: '{ALERT.SUBJECT}'
  21. 0:
  22. name: token
  23. value: <PUSHOVER TOKEN HERE>
  24. 8:
  25. name: triggerid
  26. value: '{TRIGGER.ID}'
  27. 4:
  28. name: url
  29. value: '{$ZABBIX.URL}'
  30. 5:
  31. name: url_title
  32. value: Zabbix
  33. 1:
  34. name: user
  35. value: '{ALERT.SENDTO}'
  36. max_sessions: "0"
  37. script: "try {\n//\tZabbix.Log(127, 'Pushover webhook script value='+value);\n\n\tparams
  38. = JSON.parse(value),\n\treq = new CurlHttpRequest(),\n\tfields = {};\n\n\treq.AddHeader('Content-Type:
  39. application/json');\n\n\tfields.token= params.token;\n\tfields.user = params.user;\n\n\n
  40. \ /*\n If a device name is not specified for a user, or the specified
  41. device name is no longer enabled/valid,\n notifications will be sent to
  42. all active devices for that user to avoid losing messages.\n Messages
  43. may be addressed to multiple specific devices by joining them with a comma (such
  44. as device=iphone,nexus5).\n fields.device = params.device;\n */\n\tfields.title
  45. = params.title;\n\tfields.message = params.message;\n fields.url =
  46. params.url+\"/tr_events.php?triggerid=\"+params.triggerid+\"&eventid=\"+params.eventid;\n
  47. \ fields.url_title = params.url_title;\n fields.priority = params.priority;\n\tvar
  48. resp = req.Post('https://api.pushover.net/1/messages.json',\n\t\tJSON.stringify(fields)\n\t);\n\n\tif
  49. (req.Status() != 200) {\n\t\tthrow JSON.parse(resp).errors[0];\n\t}\n\n\tresp
  50. = JSON.parse(resp);\n return \"OK\";\n\n} catch (error) {\n\tZabbix.Log(127,
  51. 'Pushover notification failed : '+error);\n throw 'Pushover notification
  52. failed : '+error;\n}"
  53. description: |-
  54. Please refer to setup guide here: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/media/pushover
  55. Set token parameter with to your Pushover application key.
  56. When assigning Pushover media to the Zabbix user - add user key into send to field.
  57. ...

Element tags

Element tag values are explained in the table below.

ElementElement propertyRequiredTypeRange1Description
media_types-Root element for media_types.
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.
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.
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.
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.