Ad Widget

Collapse

Which python API module?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LenR
    Senior Member
    • Sep 2009
    • 1005

    #1

    Which python API module?

    I have used the lukecyca pyzabbix package for years, but just hit a possible bug, I happened to see on the Zabbix integrations page that their recommended package is the abubkov/py-zabbix. I wonder why that one is recommended, the lukecyca seems more popular.
  • Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1782

    #2
    Please tell more about the possible bug.

    There is even discussion in GitHub issue that the packages are maybe merging: https://github.com/lukecyca/pyzabbix/issues/164

    pyzabbix does not have a sender, maybe that's why Zabbix is "recommending" py-zabbix. (Yes, I hate that py-zabbix managed to select the same pyzabbix namespace...)

    (And yes I'm using pyzabbix in my current projects)

    Markku

    Comment

    • LenR
      Senior Member
      • Sep 2009
      • 1005

      #3
      I just opened an issue on the lukecyca project. I'm trying to httptest.create with a longer name than I'd ever had before. This name is 68 characters long and I got error
      HTML Code:
      pyzabbix.api.ZabbixAPIException: ('Error -32602: Invalid params., Invalid parameter "/1/name": value is too long.', -32602)
      I can create the web test via the Zabbix frontend, so it looks like a limit in the module, not Zabbix.

      Comment

      • Markku
        Senior Member
        Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
        • Sep 2018
        • 1782

        #4
        Ok, let's discuss that in the issue, please submit an example there.

        Markku

        Comment

        • LenR
          Senior Member
          • Sep 2009
          • 1005

          #5
          z_url sanitized =
          Code:
          http://xxx-yyy-main.zzzz.zzzzzzzz.zzz/installation/default-en-US.htm
          API call: minimally sanitized, no guarantee on the indention here, this worked with shorter url's.
          Code:
          web_resp = zapi.httptest.create(
          {
              "name": z_url,
              "hostid": hostId,
              "delay": "240",
              "verify_host": "1",
              "verify_peer": "1",
              "steps": [
                  {
                      "name": "s1",
                      "url": z_url,
                      "status_codes": "200",
                      "no": "1",
                  }
              ],
              "tags": [
                  {"tag": "Some Tag1", "value": "urlpath"},
                  {"tag": "Application", "value": "Local Preciousness"},
              ],
          }
          )​
          Last edited by LenR; 07-12-2022, 19:29.

          Comment

          • Markku
            Senior Member
            Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
            • Sep 2018
            • 1782

            #6
            Have you tried

            a) creating the "long" test in curl? That would mean that API is working but pyzabbix is not
            ​
            b) creating the "long" test in GUI, reading it with pyzabbix, deleting in GUI, and recreating the test with the saved data in pyzabbix? (That would ensure that your input data is otherwise correct for the case)

            Markku

            Comment


            • Markku
              Markku commented
              Editing a comment
              For the case b), I think I have encountered some case where the error message from Zabbix was not actually correct, that's why I think it is useful to check the request data otherwise as well.

              Markku
          • Markku
            Senior Member
            Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
            • Sep 2018
            • 1782

            #7
            Btw what Zabbix version is this?

            Markku

            Comment

            • LenR
              Senior Member
              • Sep 2009
              • 1005

              #8
              Zabbix is 6.0, I've not done the more difficult testing, it's been a LONG TIME since I tested with curl. I'll get to it eventually, but today is my Friday.

              Comment

              • Markku
                Senior Member
                Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
                • Sep 2018
                • 1782

                #9
                Fair enough. As a general comment, pyzabbix is not mangling the data much, and there are no practical string limits in Python, so my assumption based on the case description is that the problem is in Zabbix API, not pyzabbix. But let's see later.

                Markku

                Comment

                • LenR
                  Senior Member
                  • Sep 2009
                  • 1005

                  #10
                  I agree, I did try in py-zabbix and it gets the same issue.

                  I have support, I'll open a case :-)

                  Comment

                  • Markku
                    Senior Member
                    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
                    • Sep 2018
                    • 1782

                    #11
                    My Zabbix 6.2.4 testhost truncates the web scenario name at 64 characters in GUI.

                    Markku

                    Comment

                    • LenR
                      Senior Member
                      • Sep 2009
                      • 1005

                      #12
                      Oh, I hadn't noticed that, it worked but I didn't see the shorter name. I'm not sure if that is better or worse.

                      There is nothing to protect me form a use asking for 2 urls that have the same first 64 characters. Users are the root cause here...

                      Comment

                      • Markku
                        Senior Member
                        Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
                        • Sep 2018
                        • 1782

                        #13
                        But it's just the name, right? Not the URL

                        Markku

                        Comment

                        • LenR
                          Senior Member
                          • Sep 2009
                          • 1005

                          #14
                          Right, but I was trying to use the url for the name, otherwise I'll have to invent a name.

                          Comment

                          • Markku
                            Senior Member
                            Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
                            • Sep 2018
                            • 1782

                            #15
                            Two hardest problems in IT:
                            1. Users
                            2. Naming things
                            3. Off-by-one errors



                            Markku

                            Comment

                            Working...