Ad Widget

Collapse

Unable to retrieve body information from URL with zabbix againt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SpeedyGonzalesNL
    Junior Member
    • Oct 2023
    • 23

    #1

    Unable to retrieve body information from URL with zabbix againt

    Good communictie of Zabbix.


    Im still quiet new to zabbix, but im at a point of pulling my hair out again, and not going forward.


    What im i trying to do (whole scenario)


    We have a zabbix agent running on APP02.
    On the APP02 we got 10 nodes running from SAP (see picture 0)
    These 10 nodes are running as services (but they all run by the same program)
    When we go to the node (example https://172.172.172.1:50000/ping/node/1) we get the information (see picture 1)
    But when i turn off the services for node 1, you will see the following information (see picture2)
    Now i want to get a notification saying that node1 has returned with a message : Service unavailible
    But triggers/items/web scanario dusnt want to work, and im getting no where.


    OK, now what do i want.

    When the body comes back with message "message": "Service Unavailable" i want to trigget it on dashboard, but also, i want to get a message in email/teams.

    Now i made a web scenario and trying to retrieve the body, but even getting this information back, its not working and im stuck.
    I followed the instructions https://www.zabbix.com/documentation...web_monitoring but im just getting no where.

    What im i doing wrong and why is this so hard to get it working.
    Its just a simple body that needs to get retrieved a

    If you need anymore information, please let me know.
    Attached Files
  • ISiroshtan
    Senior Member
    • Nov 2019
    • 324

    #2
    I would say you gave the description of what you want to achieve in rather complicated way. Plus it's not exactly clear for me where exactly you stumble and what the problem is.
    That said, I'll do a half-blind shot with giving an option to try, and if I misunderstood what you try to achieve - feel free to correct me.

    So, if you only care about response(body) returned by web request, I would step away from using web scenario, as it seem overkill for the task at hand, and would just use "HTTP Agent" item type.
    Create a new item for the host, type HTTP Agent, rest of the setup should be mostly the same to web scenario step I believe. Make sure to set type of information to "Text" and retrieve mode to "Body".

    This should result in you having item which either has JSON with PONG reply or the "Service Unavailable" in it's history. With that you should be able to create a trigger with expressions like
    Code:
    find(/host/key,,"regexp","Service Unavailable")=1
    Giving you the alert you want.

    Then for this alert you should be able to configure Notification Action to send email/teams (separate configuration, should be plenty of guides how to do it).


    Please do advise if something still not working or I misunderstood some of the requirements in your setup
    Last edited by ISiroshtan; 14-12-2023, 16:26.

    Comment

    • SpeedyGonzalesNL
      Junior Member
      • Oct 2023
      • 23

      #3
      Thanks for the feedback.


      So situation =

      When node1 is reachable, you will get the following feedback:

      }​
      "message": "pong",
      "sender": "node1",
      "timestamp": "1702563427.032"
      }​

      But when i turn off Node1, i will get the following message:

      {
      "message": "Service Unavailable"
      }​


      So when the last message appear, i want to get a alert on my dashboard, and get a notification in Teams channel or in email saying Disaster, services is down or something like that.

      I have Zabbix agent installed on the APP02.
      Just cant seem to get any notification.


      PS i will try your suggestion aswell
      Last edited by SpeedyGonzalesNL; 14-12-2023, 16:25.

      Comment

      • ISiroshtan
        Senior Member
        • Nov 2019
        • 324

        #4
        So you already have the item in Zabbix that contains the body of a reply in item history?
        If so - just create a trigger with function I wrote above. It should give you the alert in Zabbix.

        Comment

        • SpeedyGonzalesNL
          Junior Member
          • Oct 2023
          • 23

          #5
          Well thats the problem,

          I tried a few items, and triggers and web scanerio's but nothing is working, so just dont know what to do.

          Tried the following items:

          web.page.perf[host,<path>,<port>]
          web.page.get[host,<path>,<port>]
          web.page.regexp[host,<path>,<port>,regexp,<length>,<output>

          <path> = 172.172.1.1:50000

          But the url = 172.172.1.1:50000/ping/node/1 (and for node 2 = 2 etc etc)


          Im just stuck on how to get this simple thing working and where i need to look.
          Tried so many things that im not seeying it anymore how to get it working.

          (with everything, i got 0 results, not even text or error something)

          So clearly im doing something wrong, just dont know what the best practice is to get the result.

          Main thing, when website (body) is saying "Service Unavailable" i need to get a error message on dashboard, any clue on how to get it without much work ?

          PS, Edit with a screenshot
          Attached Files
          Last edited by SpeedyGonzalesNL; 14-12-2023, 16:36.

          Comment

          • ISiroshtan
            Senior Member
            • Nov 2019
            • 324

            #6
            So, to simplify things, Zabbix monitoring consists of 3 steps

            1. Collect data
            2. Evaluate data (for alert)
            3. (Optional) Notifications for alerts.

            If you dont have your data collected into Zabbix it's pointless to talk about alerts and notifications in email and/or teams. You need to sort data collection first, only then it makes sense to proceed further.

            Now for data collection, as I said in my original message, try to step away from web scenario. Create a new host item like follows:

            Name: whatever you want ("SAP 1 check" as example)
            Type: HTTP Agent
            Key: whatever you want ("http_get.sap.body" as example)
            Type of information: Text
            (bunch of params set same as you did in web scenario step)

            This should start bringing you the body of HTTP Get reply. WHEN it does and you can see the body of a request in latest data in Zabbix (and only after you verified it does!!!) you can proceed to creating a trigger. Function for a trigger that should work was also given in my previous messages.​

            Comment

            • SpeedyGonzalesNL
              Junior Member
              • Oct 2023
              • 23

              #7
              Its been a long day.
              I will try it tomorrow morning when i get to work and keep you updates

              Thanks for the information so far

              Comment

              • SpeedyGonzalesNL
                Junior Member
                • Oct 2023
                • 23

                #8
                Good morning Isiroshtan


                Im trying to make new item and fill in everything.
                But even after that im getting no data in the dashboard.

                Did i forgot something somewhere ?
                Thanks for the explanation so far though ^^

                Added some screenshots, hopefully it will make it a bit more clearer

                Edit1:
                I even tried json, adjusted the body (because the timestamp change everytime ofcourse) so i removed that, but it just dont want to give me the information
                Attached Files
                Last edited by SpeedyGonzalesNL; 15-12-2023, 11:16.

                Comment

                • ISiroshtan
                  Senior Member
                  • Nov 2019
                  • 324

                  #9
                  What is the state of the item when you open host for configuration of items? Does ti show any error state, like timeout or any other?

                  Also can you curl from Zabbix server CLI to website you try to monitor, does it respond?

                  Comment

                  • SpeedyGonzalesNL
                    Junior Member
                    • Oct 2023
                    • 23

                    #10
                    Other items work perfectly, and i can ping all the zabbix servers./host.

                    When checking the items on host, i get error saying: Cannot perform request: Connection timed out after 3001 milliseconds


                    Edit:
                    Also can you curl from Zabbix server CLI to website you try to monitor, does it respond?

                    What do you mean with this ?
                    Attached Files
                    Last edited by SpeedyGonzalesNL; 15-12-2023, 14:07.

                    Comment

                    • ISiroshtan
                      Senior Member
                      • Nov 2019
                      • 324

                      #11
                      So Zabbix does not get reply from the server you trying to send request to.

                      You can double check commuinication between Zabbix server and your web server by connecting to Zabbix server CLI and run something like
                      Code:
                      curl https://172.25.25.129:50000/ping/node/1 -d '{"message": "pong", "sender": "node1" }'
                      This should return you the reply that you expect to get. If it also times out - you need to check communication between Zabbix server and 172.25.25.129 node. As it seems it fails somewhere in between.

                      P.S. Are you sure your API web server don't expect any headers to be present? Usually there is a requirement for at least a Content-Type: application/json

                      Comment

                      • SpeedyGonzalesNL
                        Junior Member
                        • Oct 2023
                        • 23

                        #12
                        Just made a few screenshots.
                        Even when i use that Code on the Server (CONAPP02) im getting errors with Certificates not working.


                        Click image for larger version

Name:	screenshot06.png
Views:	1100
Size:	99.3 KB
ID:	475953

                        Comment

                        • SpeedyGonzalesNL
                          Junior Member
                          • Oct 2023
                          • 23

                          #13
                          C:\Users\username>curl https://172.25.25.129:50000/ping/node/1 -d '{"message": "pong", "sender": "node1" }'
                          curl: (60) schannel: SEC_E_UNTRUSTED_ROOT (0x80090325) - The certificate chain was issued by an authority that is not trusted.
                          More details here: https://curl.se/docs/sslcerts.html

                          curl failed to verify the legitimacy of the server and therefore could not
                          establish a secure connection to it. To learn more about this situation and
                          how to fix it, please visit the web page mentioned above.
                          curl: (3) URL rejected: Bad hostname
                          curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
                          curl: (6) Could not resolve host: node1
                          curl: (3) unmatched close brace/bracket in URL position 1:
                          }'
                          ^​


                          I cannot acces the Zabbix server its self, because its installed on Linux and i dont have any acces rights

                          But do you think its not working because i dont have a Certificate on this sap nodes ?
                          Its a test enviroment, so not a working production.

                          Comment

                          • ISiroshtan
                            Senior Member
                            • Nov 2019
                            • 324

                            #14
                            No, I dont think wrong certificate would be causing timeout error.

                            I advised to test specifically from Zabbix server CLI because so far all point to the fact that Zabbix server cant communicate to that webserver. The fact you able to do curl on your or any other machine does not really confirms nor denies said theory. I would still advise to find who has access to Zabbix CLI and ask them to do the test with curl.

                            Comment

                            • SpeedyGonzalesNL
                              Junior Member
                              • Oct 2023
                              • 23

                              #15
                              Results from the Zabbix server


                              Click image for larger version  Name:	afbeelding.png Views:	0 Size:	4.3 KB ID:	475965

                              This is all hes getting. No error just this and nothing happens


                              Pinging from Zabbixmon01 to the Ip adress works:

                              Click image for larger version

Name:	afbeelding (1).png
Views:	1079
Size:	67.1 KB
ID:	475966
                              Last edited by SpeedyGonzalesNL; 15-12-2023, 15:38.

                              Comment

                              Working...