Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save isaqueprofeta/6b05b4282695086d87a9b2c0f349d9e2 to your computer and use it in GitHub Desktop.
Save isaqueprofeta/6b05b4282695086d87a9b2c0f349d9e2 to your computer and use it in GitHub Desktop.
Curl post to zabbix api (api_jsonrpc.php)
#LOGIN
curl -i -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0","method":"user.login","params":{ "user":"myUserName","password":"myPassword"},"auth":null,"id":0}' https://zabbix.server/api_jsonrpc.php
#GET ALL HOSTS WITH NAME
curl -i -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0","method":"host.get","params":{"output": ["hostid", "name"]},"auth":"<AUTH_KEY>","id":0}' https://zabbix.server/api_jsonrpc.php
#GET ALL HOSTS WITH NAME, HOSTNAME AND IP ADDRESS
curl -i -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0","method":"host.get","params":{"output":["hostid", "host", "name"], "selectInterfaces":["ip"]},"auth":"<AUTH_KEY>","id":0}' https://zabbix.server/api_jsonrpc.php
@alansenairj
Copy link

it uses username now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment