See for the official Zabbix site.


Jump to: navigation, search

Custom parameter support for script media type


Status: v1.1

Owner: Andris Zeila


Currently Zabbix passes 3 hardcoded parameters to the Script media type scripts - send to, subject and message. Zabbix should allow user to customize the parameters that are passed to this script.


The Script media parameters are defined by media_type table exec_params field and must support new built-in alert macros:

  • {ALERT.SENDTO} - 'Send to' value from user media type configuration
  • {ALERT.SUBJECT} - 'Default subject' value from action configuration
  • {ALERT.MESSAGE} - 'Default message' value from action configuration

Frontend changes

User should be add script parameters one by one similarly to the user macros:

           Script name |             |

     Script parameters | {ALERT.SENDTO}              | Remove

                       | {ALERT.SUBJECT}             | Remove

                       | {ALERT.MESSAGE}             | Remove


                       .----------.  .----------.   .----------.  .----------.
                       |  Update  |  |  Clone   |   |  Delete  |  |  Cancel  |
                       '----------'  '----------'   '----------'  '----------'

The parameters are stored in media_type table exec_params field separated by newline character. The last parameter must also have newline character at the end. The leading and trailing whitespace characters are left intact. For example parameters:


Will be saved as


The parameters are escaped and strong quoted by server before passing them to the script.

When creating new Script media the initial 'Script parameters' fields must be pre-filled with macros compatible with the current parameter format:


Server Changes

A new macro type MACRO_TYPE_ALERT supporting {ALERT.SENDTO}, {ALERT.SUBJECT} and {ALERT.MESSAGE} macros must be added.

When processing Script media type server must expand the alert macros for each parameter, quote the resulting parameters, assemble final command line and call the script.

API changes

Media type object must support a new exec_params field.

Translation strings

  • Script parameters

Database changes

A new field must be added to media_type table:

FIELD		|exec_params	|t_varchar(255)	|''	|NOT NULL	|ZBX_NODATA

A database patch must be added to set exec_params field to {ALERT.SENDTO}\n{ALERT.SUBJECT}\n{ALERT.MESSAGE}\n for the existing Script media types.


Also discussed

  • Manual ordering of script parameters will not be implemented for now.


  • v1.1 Changed script parameter input method
  • v1.0 Initial version