Ad Widget

Collapse

web scenario request with dynamic query string?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • riBoon
    Junior Member
    • May 2017
    • 25

    #1

    web scenario request with dynamic query string?

    We have to monitor pages behind cloudflare. As requesting the page via zabbix web scenario we ran into the cloudflare cache so the site seems ok but its not.
    A way to bypass this is to request the site with a custom query string. So something like 'https://my-super-page.tld/?date=unixtime

    The easiest way would be to have a macro which represents the unixtime. But there is no such feature as I saw.
    I have no glue how to do this? Have someone else solved the same problem and show me a way?

    We are using Zabbix 5.0
  • riBoon
    Junior Member
    • May 2017
    • 25

    #2
    Ok, so nobody else check websites behind cloudflare?
    Are we the only one having this problem? Or not and I should open a feature request?

    A solution is a custom check script but the performance of web scenarios is much better. So thats why we would like to use web scenarios.

    Comment

    • ISiroshtan
      Senior Member
      • Nov 2019
      • 324

      #3
      What bout some workarounds to achieve what you want here and now? You can do the following:

      1. Create a global macro like {$UNIX_TIME}
      2. Create a shell/python/whatever script that will:3. Run said script via crontab every X (depends how oft you run your web scenario).
      4. Use said macro in your scenario

      Said script can be run on Zabbix server itself. If it's a HA cluster setup then you can add some checks inside the script before touching API to verify that Zabbix server daemon is running on current node and if not - finish the script immediately.

      You have to create said macro/script only once, and then can use it in as many scenarios as you want. So I don't think it would create too much extra load for your system. Also I'm not ready to say what permissions are needed for Zabbix user to be able to change global macro, so some testing are due to figure the least sufficient permission for the task.
      Last edited by ISiroshtan; 05-11-2021, 14:12.

      Comment

      • ISiroshtan
        Senior Member
        • Nov 2019
        • 324

        #4
        Oh damn, never even though about writing API calls inside of pre-processing. That sounds cool! Thx for insight!!! Shame I'm not much into JS

        And I agree that it's just a workaround. But I think that if you have a task in hand, better to do it with workaround now then just sit waiting when/if it will be implemented later

        Comment

        • riBoon
          Junior Member
          • May 2017
          • 25

          #5
          I agree with ISiroshtan, Thats a really cool idea.
          There is one problem at all: We are checking not with zabbix server but with proxies so the update of the unixtime macro must be pushed to the proxies first. And I'm not sure if something caches the macro values. Maybe I try it with a proxy running in debug to see what exactly is going on.
          Overall its better than nothing..

          The point with access permissions: For a general macro its surely needed superadmin permissions. So maybe I prefer a template based Macro which just needs write on a hostgroup where the template is member of.
          Last edited by riBoon; 16-11-2021, 09:55.

          Comment

          • riBoon
            Junior Member
            • May 2017
            • 25

            #6
            Ok, Script is finished based on https://blog.zabbix.com/zabbix-api-s...-and-jq/12434/
            I will attach here one script where you get the global macro ids
            And a second one where the unixtime is set. The globalmacroid has to be updated.
            The scripts have .txt added because I can't upload .sh files. But they are .sh/bash files.

            I'm testing now the rest of the idea.
            Attached Files

            Comment

            • riBoon
              Junior Member
              • May 2017
              • 25

              #7
              Ok, it's working.
              For perfect use we would like to add the unixtime macro in another one (which sets the Path), but that doesn't worked. Means: {$PATH} => "/blabla/?param={$UNIXTIME}" is not possible.
              So we had to modify the Web Scenario Check in every host we want to use this.

              Maybe someone knows a better solution for that?

              Comment

              • ISiroshtan
                Senior Member
                • Nov 2019
                • 324

                #8
                Hm, could you explain in more details regarding {$PATH} and what is the issue you trying to solve?

                As I understand web scenario should be something like:
                URL: website/blabla
                Query fields:
                param => {$UNIXTIME}

                If so I think it's optimal way. If issue is updating multiple web scenarios(which can be tedious) than better to look how to update them with API. It's decent time investment into preparing a script to do the needed update first time, but in future it can be reused pretty fast and simplifies the said task.

                Sorry if I totally misunderstood the question here.

                Comment

                • riBoon
                  Junior Member
                  • May 2017
                  • 25

                  #9
                  Thanks for your help, but our setup is way to special to describe. It's ok for now.

                  Comment

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

                    #10
                    Originally posted by ISiroshtan
                    Hm, could you explain in more details regarding {$PATH} and what is the issue you trying to solve?
                    I think his case was about using one macro in other macros value... {$PATH} => /blabla/?param={$UNIXTIME}
                    that macro inside a macro cannot be done.

                    Comment

                    • riBoon
                      Junior Member
                      • May 2017
                      • 25

                      #11
                      Originally posted by cyber

                      I think his case was about using one macro in other macros value... {$PATH} => /blabla/?param={$UNIXTIME}
                      that macro inside a macro cannot be done.
                      Yes, that's it. Because we can configure this via host macro and not inside a web scenario. Which is more obvious to the zabbix user who doesn't know much details about zabbix.
                      But beside that the solution is ok, it works. It's not perfekt, but that doesn't matter.

                      Comment

                      Working...