Advertisement
kazoda

Zabbix api sh

Aug 6th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.54 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Refer to https://github.com/zembutsu/zabbix-api-tools/blob/master/auth.sh
  4.  
  5. ## Usage ./zab.sh json_file
  6.  
  7. json='{"jsonrpc":"2.0","method":"user.login","params":{"user":"Admin","password":"zabbix"},"id":1}'
  8. authid=$(curl -s -XGET -H"Content-Type:application/json-rpc" -d$json http://10.0.3.10/zabbix/api_jsonrpc.php | jq -r '.result')
  9.  
  10. json=$(cat $1 | jq -r "." -c | sed -e s/AUTH_ID/$authid/g)
  11. echo $json
  12. curl -s -XGET -H"Content-Type:application/json-rpc" -d$json http://10.0.3.10/zabbix/api_jsonrpc.php | jq -r '.result'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement