Ad Widget

Collapse

API for Trigger.Get missing expandURL flag

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mdiorio
    Junior Member
    • Mar 2016
    • 27

    #1

    API for Trigger.Get missing expandURL flag

    I'm using Grafana-Zabbix and the new Trigger Panel to show my host triggers.

    So my Triggers for website monitoring are all templated and working properly. I have a URL on the trigger with a Macro in it and it works fine within Zabbix. I can view the trigger and open the URL and it processes the macro

    http://{HOST.HOST}/content-check/checknow.cfm?mode=all

    The Trigger Panel is not getting the macro converted. I'm getting an URL encoded, un-converted macro

    http://%7Bhost.host%7D/content-check...w.cfm?mode=all

    In the API, you have flags for:
    expandComment flag Expand macros in the trigger comment.
    expandDescription flag Expand macros in the name of the trigger.
    expandExpression flag Expand functions and macros in the trigger expression.
    But there is no equivalent for expandURL, so as you can see, macros don't get expanded when requested through the API.

    Please implement this or feel free to bash me if I'm missing something

    Thanks.

    Max
  • cdslaughter
    Member
    • Jun 2018
    • 69

    #2
    I have run into this issue too. I am running 4.0.3 and have fixed it by modifying the following file as below

    include/classes/api/services/CTrigger.php

    Added to following to the parameters section
    Line 99
    Code:
                            'expandURL'                                     => true,     // Added so that the API returns translated URLs
    Inserted at line 467 (Between "expandComment" and "expand expression"

    Code:
                    // expandURL                    Added to ensure that the API returns URLs with correct value and not the macro placeholder
                    if (!is_null($options['expandURL']) && $result && array_key_exists('url', reset($result))) {
                            $result = CMacrosResolverHelper::resolveTriggerUrls($result);
                    }

    Comment

    Working...