Ad Widget

Collapse

Name of macro being passed to Web Scenario not the result of macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Judge_Dredd
    Junior Member
    • Feb 2023
    • 17

    #1

    Name of macro being passed to Web Scenario not the result of macro

    Hi all
    I am trying to get a web scenario working with a dynamic date. First of all I will explain what does work.


    1) Have set up 2 macros - lets call them {$BEGIN} and {$END}. For the values in the macros I add a date 30 days {$BEGIN} from today and in the second 40 days from today {$END}
    2) I add a Web scenario to a Host. The step has several pieces of data including the {$BEGIN} and {$END} macros.

    This is set to check every 5 mins and what it is giving me is the response time for the website to give a result - this works fine.


    The problem is that the dates for this website need to both be in the future - the way it stands at the moment, we are regularly having to change the values in the macros. What we would like is the date in the value field in the macro comes from a macro such as {$__date_add({$DATE},30d,)} and {$__date_add({$DATE},40d,)} in the value fields.

    When trying this, the macro name (not the actual result of the macro in the value field) is passed to the {$BEGIN} and {$END} macros. This in turn means that the macro names (e.g. {$__date_add({$DATE},30d,)}) is queried against the website in the request string and not the actual dates.

    So my question here is how do I do this? Is this possible?

    Any assist would be greatly appreciated

    Cheers
    Marc​
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Use script item and write your full logic in JS... ?

    Comment

    • Judge_Dredd
      Junior Member
      • Feb 2023
      • 17

      #3
      Thanks for that cyber - worked like a charm till I discovered that host item values cannot be updated into a macro in zabbix (which I didn't say in the post that was what I was attempting). The script I wrote updated a script item but I couldn't get that data into into a macro. I'm now looking at running a python script in a cron job and updating a macro that way. What I'm trying to accomplish is have a date in a web scenario to be today plus 30 - the date is part of a query string in the web scenario to one of our websites and we monitor the request times to make sure they aren't running amok.
      Thanks for your help - greatly appreciated

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        You can run a API call in javascript to update a macro..
        You can have a separate scheduled item, that does all that javascript magic, what creates values for macros, runs every 24h, updates global macros and you can use those in your other items.

        Comment

        Working...