参考:
示例:
POST
http://10.*.*.*:8181/api_jsonrpc.php
HEADER
Content-Type: application/json-rpc
BODY
{
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "admin",
"password": "admin"
},
"id": 1,
"auth": null
}
# 获取认证token
RESPONSE
{
"jsonrpc": "2.0",
"result": "137f9ec07ed1ab2c0a86ab3dadccd165",
"id": 1
}
BODY
{
"jsonrpc": "2.0",
"method": "host.get",
"params": {
"output": [
"hostid"
],
"search":{
"host":46
}
},
"id": 2,
"auth": "dc30a97682e4bd32f9a7989f8660b4c7"
}
#获取监控主机ID
RESPONSE
{
"jsonrpc": "2.0",
"result": [
{
"hostid": "10111"
}
],
"id": 2
}
BODY
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": ["itemid","delay"],
"hostids": "10111",
"search": {
"name": "service_gw"
}
},
"auth": "c7c48251052d2fd02ac9d78eea612b92",
"id": 1
}
#获取监控项ID和更新周期(秒)
RESPONSE
{
"jsonrpc": "2.0",
"result": [
{
"itemid": "25618",
"delay": "30"
}
],
"id": 1
}
BODY
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": ["itemid","delay"],
"hostids": "10111",
"webitems": "true",
"search": {
"key_": "openab_web",
"name": "Response code"
},
"sortfield": "name"
},
"auth": "c7c48251052d2fd02ac9d78eea612b92",
"id": 1
}
#获取web监控项ID和更新周期(秒)
RESPONSE
{
"jsonrpc": "2.0",
"result": [
{
"itemid": "25579",
"delay": "5"
}
],
"id": 1
}
BODY
{
"jsonrpc": "2.0",
"method": "history.get",
"params": {
"output": "extend",
"history": 3,
"itemids": "25579",
"sortfield": "clock",
"sortorder": "DESC",
"limit": 1
},
"auth": "c7c48251052d2fd02ac9d78eea612b92",
"id": 1
}
RESPONSE
{
"jsonrpc": "2.0",
"result": [
{
"itemid": "25579",
"clock": "1494380505",
"value": "200",
"ns": "159533255"
}
],
"id": 1
}
网友评论