See for the official Zabbix site.


Jump to: navigation, search

Hierarchical menu structure for global scripts


Status: v1.4

Owner: Alexei


Menu structure should support hierarchical placement of global scripts. For example:

    |-Software reboot
    |-Hardware reset
  | - Traceroute
  | - ICMP ping
  | - SSH ping

Number of menu levels shouldn't be artificially limited, it is limited by the maximum length of script name only.

Interface changes


Script name may contain '/' which is a delimiter for menu levels, Menu/Sub-menu/Sub-menu/Script

For example:

 Management/Reboot/Software reboot

Empty (sub)menu names and scripts names (also */) are not allowed. The following error messages will be generated:

 Empty name for script.                         # the name is completely blank
 Empty name for script "%scriptName%".          # for cases like "menu/"
 Incorrect menu path for script "%scriptName%". # for cases like "menu//script"

A single backslash escapes any symbol directly after it. For example, characters '/' and '\' can be escaped by backslash, i.e. \/ or \\.

A placeholder '<Sub-menu/Sub-menu.../>Script' should be displayed in the script name input.

A script cannot have the same name as an existing directory.

For example:

 Management/Reboot/Software reboot
 Management/Reboot                  # directory "Management/Reboot" already exists


 Management/Reboot/Software reboot/Force reboot # Script "Management/Reboot" already exists

Script name must be unique only in actual folder scope, in other folders scripts with exact same name may exist. Unescaped script names should be validated for uniqueness, i.e. "Ping" and "\Ping" cannot be added in the same folder.

Script name and script folder name must be trimmed.


The host menu should be redesigned to have support of sub-menus. Sub-menus should differ visually from regular menu items. Ideally style of the menu should be improved to make it nicer yet easy to use.

Database changes

  • A database patch must be created to escape characters '/' and '\' in existing script names.

Implementation details

  • The HTML code of the menu must be generated by JavaScript when clicking on the menu link.
  • When creating a menu on the client side, all of the required parameters must be passed to a helper function which will generate an array containing the structure of the menu. That array must then be passed to a separate function that will generate the HTML code of the menu.
  • Each menu type (host, trigger, item and map element) must have its own helper function.
  • The menu click handler should be bound to the HTML object via a special class name for each menu type. Something like 'menu-host', 'menu-trigger' etc.
  • All of the required data must be passed to JS via a JSON object stored in the 'data-menu' attribute.
  • For the popups in the value mode in Monitoring -> Overview, sections Graphs and Values will be merged in a single entry History.

The implementation should be similar (not necessarily the same) to the current implementation of host menus.

Translation strings

  • <Sub-menu/Sub-menu.../>Script
  • Empty name for script.
  • Empty name for script "%scriptName%".
  • Incorrect menu path for script "%scriptName%".

Testing notes

  • Make sure that new code for menu calling has the same or smaller size of HTML/JS code.



  • v1.1
    • Added error message "Menu or script name cannot be empty".
  • v1.2
    • Better error messages.
  • v1.3
    • Note that value/graph entries will be merged in overview.
  • v1.4
    • A script cannot have the same name as an existing directory.
  • v.1.5
    • Script name must be unique only in actual folder scope, in other folders can be scripts with similar name.
  • v.1.6
    • Script name and script folder name must be trimmed.