Customizing Zabbix popup menus

If you want to add a custom menu item to the site popup menu you can do so by adding it into one of the zabbix javascript files.  In the screenshot below I have added an option referred to as Site infob which when you click on the host object it and click on it you will be redirected to a page of my choosing.

The file to edit is menupopup.js and it resides in the /js sub-directory in the zabbix front end folder (i.e. /usr/share/zabbix/js).

Note: Backup this file before and after any changes so you can rollback and to protect against future zabbix frontend upgrades which would overwrite this file and all your customizations.

Step 1


if (options.hasGoTo) {
// inventory
var host_inventory = {
label: t('Host inventory')
},
host_inventory_url = new Curl('hostinventories.php', false),
// latest
latest_data = {
label: t('Latest data')
},
latest_data_url = new Curl('latest.php', false),
// problems
problems = {
label: t('Problems')
},
// basic info
siteinfo = {
label: t('Site info')
},
// graphs
graphs = {
label: t('Graphs')
},

Step 2

Around line 185 in menupopup.js but before the line containing sections.push({

Add in the following noting I am appending the hostid as an argument so my example below would go to http://targeturl_goes_here?hostid=12345


var siteinfo_url = new Curl('http://targeturl_goes_here', false);

siteinfo_url.setArgument('hostid', options.hostid);

siteinfo.url = siteinfo_url.getUrl();

Final Step

Edit the sections.push section to activate your new menu item.


sections.push({
label: t('Go to'),
items: [
host_inventory,
latest_data,
problems,
graphs,
siteinfo,
screens
]
});

Limitations

There are some limitations such as the arguments zabbix can append to the URL are triggerid, hostid and name where you might want something different such as host IP Address to be appended to the target url. I have worked around this in the past by using a redirection page which I used to lookup the hostid retrieve the attribute(s) I wanted and replace and redirect to the target url.

Back To Top