Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Refer to https://github.com/zembutsu/zabbix-api-tools/blob/master/auth.sh
- ## Usage ./zab.sh json_file
- json='{"jsonrpc":"2.0","method":"user.login","params":{"user":"Admin","password":"zabbix"},"id":1}'
- authid=$(curl -s -XGET -H"Content-Type:application/json-rpc" -d$json http://10.0.3.10/zabbix/api_jsonrpc.php | jq -r '.result')
- if [ $1 = "history_get.json" ]; then
- while read line
- do
- json=$(cat $1 | jq -r "." -c | sed -e s/AUTH_ID/$authid/g -e s/ITEM_ID/$line/g)
- echo "ITEM-ID: $line"
- curl -s -XGET -H"Content-Type:application/json-rpc" -d$json http://10.0.3.10/zabbix/api_jsonrpc.php | jq -r '.result'
- #sleep 10
- done < item.list
- else
- json=$(cat $1 | jq -r "." -c | sed -e s/AUTH_ID/$authid/g)
- curl -s -XGET -H"Content-Type:application/json-rpc" -d$json http://10.0.3.10/zabbix/api_jsonrpc.php | jq -r '.result'
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement