Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
J
jfzabbix
  • Overview
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • jfmonitor
  • jfzabbix
  • Wiki
  • 获取cpu使用率

获取cpu使用率

Last edited by zhengtianbao Apr 12, 2018
Page history

获取item id

获取cpu使用率system.cpu.util[all,idle,avg1]的itemid

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 %

Clone repository
  • Home
  • Zabbix api ref
  • Zabbix_agent安装配置
  • Zabbix_server安装配置
  • 产品原型图
  • 创建报警规则
  • 创建用户组, 用户
  • 删除报警规则
  • 删除用户, 用户组
  • 测试脚本
  • 登入登出
  • 获取cpu使用率
  • 获取主机信息
  • 获取内存使用率
  • 获取报警信息
More Pages
×

New Wiki Page

Tip: You can specify the full path for the new file. We will automatically create any missing directories.