Advertisement
Guest User

Untitled

a guest
Jan 18th, 2021
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. zbxUser='abc'
  2.  
  3. zbxPass='123456'
  4.  
  5. zbxAPI='http://localhost/zabbix/api_jsonrpc.php'
  6.  
  7.  
  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.  
  14.  
  15. post=$(printf '{"jsonrpc":"2.0","method":"trigger.get","params":{"hostids":10663,"filter":{"value":1},"output":["description","priority"]},"id":0,"auth":"%s"}' ${auth})
  16.  
  17.  
  18.  
  19. $data=`curl -sX POST -H 'Content-Type: application/json-rpc' -d "${post}" "${zbxAPI}"`
  20.  
  21.  
  22.  
  23. for priority in 5 4 3 2 1 ;
  24.  
  25. do
  26. echo $($data | grep -o '"priority":"$priority"' | wc -l)
  27. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement