doumengbai2031 2019-07-31 05:05
浏览 123

如何在Zabbix的弹出菜单中为触发器添加自定义链接?

I need to add a custom link for my hosts in Zabbix trigger popupmenu. Zabbix has a section in Dashboard for show triggers and when we click on each Hostname, a popup menu opened and there is some default links.

Now i need to add a link for hosts that when we click on it, open a new page for control Panel or every related page.

There is some solution but all of them was for older versions:

https://support.zabbix.com/browse/ZBXNEXT-3496

https://github.com/v-zhuravlev/zabbix-hostmenu

There is two file that i can modify and add new custom link to popupmenu or add a new column with new link.

1- /usr/share/zabbix/js/menupopup.js

2- /usr/share/zabbix/app/views/monitoring.widget.problems.view.php

For now The link added successfully from 2 ways but i need to use Macro (Hostname, Hostip , ...) in the link url.

File: menupopup.js

 // go to section
    if (options.hasGoTo) {
        // inventory
        var
            //My Custom Link
            rd_data = { label: t('Remote Link')},
            rd_qurl = 'http://remote.mydomain.com/Host#Access/Connected Systems/'+{HOST.NAME},
            rd_data_url = new Curl(rd_qurl, false),

            // host inventory           
            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')
            },
            // graphs
            graphs = {
                label: t('Graphs')
            },
            // screens
            screens = {
                label: t('Host screens')
            };

        //My Custom Link
        rd_data.url = rd_data_url.getUrl();

        // inventory link
        host_inventory_url.setArgument('hostid', options.hostid);
        host_inventory.url = host_inventory_url.getUrl();

        // latest data link
        if (typeof options.filter_application !== 'undefined') {
            latest_data_url.setArgument('application', options.filter_application);
        }
        latest_data_url.setArgument('hostids[]', options.hostid);
        latest_data_url.setArgument('filter_set', '1');
        latest_data.url = latest_data_url.getUrl();

        if (!options.showTriggers) {
            problems.disabled = true;
        }
        else {
            var url = new Curl('zabbix.php', false);
            url.setArgument('action', 'problem.view');
            url.setArgument('filter_hostids[]', options.hostid);
            if (typeof options.severity_min !== 'undefined') {
                url.setArgument('filter_severity', options.severity_min);
            }
            if (typeof options.show_suppressed !== 'undefined' && options.show_suppressed) {
                url.setArgument('filter_show_suppressed', '1');
            }
            if (typeof options.filter_application !== 'undefined') {
                url.setArgument('filter_application', options.filter_application);
            }
            url.setArgument('filter_set', '1');
            problems.url = url.getUrl();
        }

        if (!options.showGraphs) {
            graphs.disabled = true;
        }
        else {
            var graphs_url = new Curl('charts.php', false);

            graphs_url.setArgument('hostid', options.hostid);
            graphs.url = graphs_url.getUrl();
        }

        if (!options.showScreens) {
            screens.disabled = true;
        }
        else {
            var screens_url = new Curl('host_screen.php', false);

            screens_url.setArgument('hostid', options.hostid);
            screens.url = screens_url.getUrl();
        }

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

You can see my modify section with name "//My custom link".

Anyway i need to use Marco "{HOST.NAME}" at the end of my url.

How can i add this Marco on this code ?

Regards,

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!