item
id
获取获取cpu使用率system.cpu.util[all,idle,avg1]的item
id
Payload:
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": ["itemid","hostid","key_","value_type","status","units"],
"hostids": "10254",
"search": {
"key_": "system.cpu.util[all,idle,avg1]"
},
"sortfield": "name"
},
"auth": "54ec7f0d103f635ada0a76147d8a93a5",
"id": 1
}
value_type:
Possible values:
0 - numeric float;
1 - character;
2 - log;
3 - numeric unsigned;
4 - text.
status:
Possible values:
0 - enabled item;
1 - disabled item.
Response:
{
"jsonrpc": "2.0",
"result": [
{
"itemid": "28314",
"hostid": "10254",
"key_": "system.cpu.util[all,idle,avg1]",
"value_type": "0",
"status": "0",
"units": "%"
}
],
"id": 1
}
history
获取Payload:
{
"jsonrpc": "2.0",
"method": "history.get",
"params": {
"output": "extend",
"history": 0,
"itemids": "28314",
"sortfield": "clock",
"sortorder": "DESC",
"limit": 10
},
"auth": "54ec7f0d103f635ada0a76147d8a93a5",
"id": 1
}
history:
Possible values:
0 - numeric float;
1 - character;
2 - log;
3 - numeric unsigned;
4 - text.
time_from: timestamp
time_till: timestamp
Response:
{
"jsonrpc": "2.0",
"result": [
{
"itemid": "28314",
"clock": "1523497194",
"value": "97.2349",
"ns": "541351565"
},
{
"itemid": "28314",
"clock": "1523497134",
"value": "96.8289",
"ns": "346086399"
},
{
"itemid": "28314",
"clock": "1523497074",
"value": "96.9414",
"ns": "179738518"
},
{
"itemid": "28314",
"clock": "1523497014",
"value": "97.1501",
"ns": "23789418"
},
{
"itemid": "28314",
"clock": "1523496954",
"value": "96.1780",
"ns": "801732652"
},
{
"itemid": "28314",
"clock": "1523496894",
"value": "96.6474",
"ns": "561848810"
},
{
"itemid": "28314",
"clock": "1523496834",
"value": "96.3763",
"ns": "295180812"
},
{
"itemid": "28314",
"clock": "1523496774",
"value": "96.3977",
"ns": "482581135"
},
{
"itemid": "28314",
"clock": "1523496714",
"value": "95.7907",
"ns": "409420477"
},
{
"itemid": "28314",
"clock": "1523496654",
"value": "95.4600",
"ns": "67662626"
}
],
"id": 1
}
注意: 这里获取的是最后10个cpu空闲百分百值, 因此cpu使用率值应为100-value %