zabbix

作者: AEGQ | 来源:发表于2017-05-10 08:46 被阅读10次

    参考:


    示例:


    • URL + HEADER
    POST
         http://10.*.*.*:8181/api_jsonrpc.php
    
    HEADER 
        Content-Type: application/json-rpc
    
    • user.login
    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
    }
    
    • host.get
    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
    }
    
    • item.get
    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
    }
    
    
    • item.get (web)
    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
    }
    
    • history.get
    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
    }
    

    相关文章

      网友评论

          本文标题:zabbix

          本文链接:https://www.haomeiwen.com/subject/djywtxtx.html