Ad Widget

Collapse

How to get latest problems using zabbix API?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • registration_is_lame
    Senior Member
    • Nov 2007
    • 148

    #1

    How to get latest problems using zabbix API?

    I'm new to API and I'm trying to figure out how to get latest problems using API. Can anyone help with this?


    curl -i -X POST -H 'Content-Type: application/json' -d '
    {
    "jsonrpc": "2.0",
    "method": "trigger.get",
    "params": {
    "filter": {"value": "1"},
    "sortfield": "lastchange"
    "limit": 20
    },
    "auth": "as;lkjda;ldsjalkjda;",
    "id": 1
    }' http://127.0.0.1/zabbix/api_jsonrpc.php


    but I get 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}


  • ZaBeast
    Member
    • Sep 2019
    • 42

    #2
    Authenticate to get token:
    curl -k -X POST https://10.10.10.161/zabbix/api_jsonrpc.php -H 'Content-Type:application/json' -d '{"jsonrpc": "2.0","method":"user.login","params": {"user": "Admin","password": "zabbix"},"id": 1,"auth": null}'
    {"jsonrpc":"2.0","result":"808b34d0dac3bf697b99ffb 23d3d3022","id":1}

    After that use that token to make API calls, for example, getting all problems:
    curl -k -X POST https://10.10.10.161/zabbix/api_jsonrpc.php -H 'Content-Type:application/json' -d '{"jsonrpc":"2.0","method":"problem.get","params ": {},"auth":"808b34d0dac3bf697b99ffb23d3d3022","id": 1}'


    Zabbix API documentation:
    https://www.zabbix.com/documentation...ce/problem/get

    Use python to simplify your life:
    Python modules for zabbix. Contribute to adubkov/py-zabbix development by creating an account on GitHub.



    Regards

    Comment

    • bbrendon
      Senior Member
      • Sep 2005
      • 870

      #3
      The GUI shows 22 problems (including suppressed). The API shows 178. Any idea why that might be?
      Unofficial Zabbix Expert
      Blog, Corporate Site

      Comment

      Working...