zoukankan      html  css  js  c++  java
  • Zabbix API获取监控项的值

    使用history.get API进行监控项的获取,进行排序和limit就可以取到最新值;

    1.1 如何进行API认证?

    获取认证中的result认证值,在后面的请求中使用;

    curl -X POST 
      http://IP:Port/zabbix/api_jsonrpc.php 
      -H 'Content-Type: application/json' -d '{
        "jsonrpc": "2.0",
        "method": "user.login",
        "params": {
            "user": "Admin",
            "password": "zabbix"
        },
        "id": 1
    }'

    返回结果是:

    {
        "jsonrpc": "2.0",
        "result": "f3f5xxx69e958",
        "id": 1
    }

    1.2 如何获取某一个监控项的值?

    使用的方法是history.get;其中的history表示数据类型;limit=1表示只取一条记录,再按照时间倒排就可以取到最新值;
    history取值:0-浮点,1-字符,2-日志,3-整数(默认),4-文本;

    itemids可以在zabbix界面查看到,点击查看该监控项的图形可以在地址栏上面看到;

    auth的值就是上一步获取的认证结果;

    curl -X POST 
      http://IP:Port/zabbix/api_jsonrpc.php 
      -H 'Content-Type: application/json' -d '{
        "jsonrpc": "2.0",
        "method": "history.get",
        "params": {
            "output": "extend",
            "history": 3,
            "itemids": "30632",
            "sortfield": "clock",
            "sortorder": "DESC",
            "limit": 1
        },
        "auth": " f3f5xxx69e958",
        "id": 1
    }'

    返回结果:

    {
        "jsonrpc": "2.0",
        "result": [
            {
                "itemid": "30632",
                "clock": "1603271688",
                "value": "812304",
                "ns": "882748120"
            }
        ],
        "id": 1
    }
  • 相关阅读:
    在WPF中判断是是否为设计时模式(转)
    后缀数组小结
    运算符重载,输出流运算符重载
    ZOJ 3699
    米勒罗宾大素数测定
    FZU 2109 Mountain Number 数位DP
    考试复习
    java文件输入输出
    纯虚函数与抽象类
    转载:stream iterators C++ 用法
  • 原文地址:https://www.cnblogs.com/stono/p/13857109.html
Copyright © 2011-2022 走看看