Ad Widget

Collapse

Problem with API (py-zabbix)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with API (py-zabbix)

    Hi All,

    Since the migration of my zabbix server (3.0 to 3.2), we have problem with the API.
    We are using py-zabbix but now we have the following error.

    {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}
    The problem seems not coming from the module because I tried with curl and I have the same issue

    # curl -k -H "Content-Type: application/json" --data @version https://myzabbix/api_jsonrpc.php

    {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}

    # cat version
    {

    "jsonrpc": "2.0",
    "method": "apiinfo.version",
    "params": [],
    "id": 1

    }
    # curl -k -H "Content-Type: application/json" --data @data https://myzabbix/api_jsonrpc.php

    {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}

    # cat data
    {

    "jsonrpc": "2.0",
    "method": "user.login",
    "params": {

    "user": "MyzabbixAPI",
    "password": "MyPass"

    },
    "id": 1

    }
    # cat version | json_verify
    JSON is valid
    Thank you in advance for your help.

    #2
    Test command is correct:
    Code:
     curl -k -H "Content-Type: application/json" --data @version http://zabbix.org/zabbix/api_jsonrpc.php
    {"jsonrpc":"2.0","result":"3.3.0","id":1}
    Problem can be your network (for example big brother proxy in your network), test it directly on zabbix server
    or
    your zabbix server (for example malconfigured web server/server modules/PHP limits, https, ...) - try to test it with minimal vanilla web server configuration, ....
    Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
    My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

    Comment


      #3
      Thank you for your quick answer.
      I will investigate the network part and test on the server.

      Comment


        #4
        Hello,

        On the zabbix server I have the same issue :

        It is fine on the zabbix.org server

        Code:
        $ curl -k -H "Content-Type: application/json" --data @version https://zabbix.org/zabbix/api_jsonrpc.php
        {"jsonrpc":"2.0","result":"3.3.0","id":1}$
        Local :
        Code:
        $ curl -k -H "Content-Type: application/json" --data @version https://127.0.0.1/api_jsonrpc.php
        {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}$
        Thanks in advance

        Comment


          #5
          I'm having the same issue with Zabbix 3.2.2 and Zabbix Gnomes python API, have you found a solution?

          Comment


            #6
            Fixed

            I fix this in our environment by moving an older version of pyzabbix over from a working box.

            For whatever reason the version of pyzabbix that pip installed has a bunch of cruft in it. I've attached our working version of pyzabbix, see if it works for you. If you're on python 2.7.

            Unpack to:
            /usr/lib/python2.7/site-packages/pyzabbix

            Hope this helps.
            Attached Files

            Comment


            • roberdaniel
              roberdaniel commented
              Editing a comment
              Hi Troseph, we are having the same problem with zabbix 4.2
              You said that you solved the problem reinstalling py-zabbix, but you had the problem also with cURL (wich nothing have to do with py-zabbix) so please explain what do you do in server side.
              Regards

            #7
            Resolved using Invoke-RestMethod instead of Invoke-WebRequest. (powershell), so i'm suspecting that the api has changed to "restful"
            I'm using Zabbix 4.2
            Can anyone confirm if api has changed?

            Comment

            Announcement

            Collapse
            No announcement yet.
            Working...
            X