https://www.zabbix.com/documentation/4.0/zh/manual
獲取令牌
[root@zabbix ~]# curl -X POST -H "Content-Type: application/json-rpc" -d '> {
> "jsonrpc": "2.0",
> "method": "user.login",
> "params": {
> "user": "Admin",
> "password": "zabbix"
> },
> "id": 1,
> "auth": null
> }' "http://10.0.0.71/zabbix/api_jsonrpc.php"
{"jsonrpc":"2.0","result":"0bba91a39dc3c0adb4553cb85661e22d","id":1}[root@zabbix ~]#
0bba91a39dc3c0adb4553cb85661e22d
查詢用戶信息
[root@zabbix ~]# curl -X POST -H "Content-Type: application/json-rpc" -d '> {
> "jsonrpc": "2.0",
> "method": "user.get",
> "params": {
> "output": "extend"
> },
> "auth": "0bba91a39dc3c0adb4553cb85661e22d",
> "id": 1
> }' "http://10.0.0.71/zabbix/api_jsonrpc.php"
{"jsonrpc":"2.0","result":[{"userid":"1","alias":"Admin","name":"Zabbix","surname":"Administrator","url":"","autologin":"1","autologout":"0","lang":"zh_CN","refresh":"30s","type":"3","theme":"default","attempt_failed":"0","attempt_ip":"10.0.0.1","attempt_clock":"1583380593","rows_per_page":"50"},{"userid":"2","alias":"guest","name":"","surname":"","url":"","autologin":"0","autologout":"15m","lang":"en_GB","refresh":"30s","type":"1","theme":"default","attempt_failed":"0","attempt_ip":"","attempt_clock":"0","rows_per_page":"50"}],"id":1}[root@zabbix ~]#
創建用戶
[root@zabbix ~]# curl -X POST -H "Content-Type: application/json-rpc" -d '
{
"jsonrpc": "2.0",
"method": "user.create",
"params": {
"alias": "wy",
"passwd": "123456",
"usrgrps": [
{
"usrgrpid": "7"
}
]
},
"auth": "0bba91a39dc3c0adb4553cb85661e22d",
"id": 1
}' "http://10.0.0.71/zabbix/api_jsonrpc.php"
{"jsonrpc":"2.0","result":{"userids":["3"]},"id":1}[root@zabbix ~]#