Advertisement
Guest User

Aaaaa

a guest
Jan 18th, 2021
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. zbxUser='abc'
  4.  
  5. zbxPass='123456'
  6.  
  7. zbxAPI='http://localhost/zabbix/api_jsonrpc.php'
  8.  
  9. post=$(printf '{"jsonrpc":"2.0","method":"user.login","params":{"user":"%s","password":"%s"},"id":0,"auth":null}' ${zbxUser} ${zbxPass})
  10.  
  11. auth=$(curl -sX POST -H 'Content-Type: application/json-rpc' -d "${post}" "${zbxAPI}" | grep -Po '(?<="result":")([a-z0-9]+)')
  12.  
  13. post=$(printf '{"jsonrpc":"2.0","method":"trigger.get","params":{"hostids":10663,"filter":{"value":1},"output":["description","priority"]},"id":0,"auth":"%s"}' "${auth}")
  14.  
  15. data=$(curl -sX POST -H 'Content-Type: application/json-rpc' -d "${post}" "${zbxAPI}")
  16.  
  17. for priority in {5..1};
  18.  
  19. do
  20.  
  21. echo "$data" | grep -o "priority\":""$priority"\"
  22.  
  23. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement