Zabbix API calls

To check API version 

Option 1: As per Zabbix doc

curl --request POST \

         --url 'http://34.42.61.202/zabbix/api_jsonrpc.php' \

         --header 'Content-Type: application/json-rpc' \

         --data '{"jsonrpc":"2.0","method":"apiinfo.version","params":{},"id":1}'


Option 2: 

curl -X POST \

  -H "Content-Type: application/json" \

  -d '{"jsonrpc":"2.0","method":"apiinfo.version","params":{},"id":1}' \

  http://34.42.61.202/zabbix/api_jsonrpc.php




-----------------------------------------------------------------------------------------------------------------------------

To authenticate the user

Option 1: As per Zabbix doc

curl --request POST \

  --url 'http://34.42.61.202/zabbix/api_jsonrpc.php' \

  --header 'Content-Type: application/json-rpc' \

  --data '{"jsonrpc":"2.0","method":"user.login","params"{"username":"Admin","password":"zabbix"},"id":1}'


Option2:

curl -X POST \

-H "Content-Type: application/json" \

-d '{"jsonrpc":"2.0","method":"user.login","params":{"username":"Admin","password":"zabbix"},"id":1,"auth":null}' \

http://34.42.61.202/zabbix/api_jsonrpc.php


Option3:

curl -X POST -H "Content-Type: application/json" \

-d '{

    "jsonrpc": "2.0",

    "method": "user.login",

    "params": {

        "username": "Admin",

        "password": "zabbix"

    },

    "id": 1,

    "auth": null

}' http://34.42.61.202/zabbix/api_jsonrpc.php


-----------------------------------------------------------------------------------------------------------------------------

Retrieve the host details

vi data.json


{

    "jsonrpc": "2.0",

    "method": "host.get",

    "params": {

        "output": ["hostid", "host", "name"],

        "selectInterfaces": ["interfaceid", "ip"]

    },

    "auth": "PASTE_YOUR_TOKEN_HERE",

    "id": 2

}


curl -X POST -H "Content-Type: application/json" \

-d @data.json http://34.42.61.202/zabbix/api_jsonrpc.php


Comments

Popular posts from this blog

How to enable the syslog monitoring-Zabbix

Zabbix installation: Distribution setup

API & API in Zabbix