获取

描述

integer/array httptest.get(object parameters)

该方法允许根据给定参数检索 Web 场景。

此方法对任何类型的用户均可用。 调用该方法的权限可在用户角色设置中撤销。 更多信息请参见 用户角色

参数

(object) 定义所需输出的参数。

该方法支持以下参数。

参数 类型 描述
groupids ID/array 仅返回属于给定主机组的 Web 场景。
hostids ID/array 仅返回属于给定主机的 Web 场景。
httptestids ID/array 仅返回具有给定 ID 的 Web 场景。
inherited boolean 如果设置为 true,则仅返回从模板继承的 Web 场景。
inheritedTags boolean 返回在 template/host/linked templates 中也具有给定 tags 的 Web 场景。

可能的值:
true - template/host/linked templates 也必须具有给定标签;
false - (默认) 忽略来自 template/host/linked templates 的标签。
monitored boolean 如果设置为 true,则仅返回属于受监控主机的已启用 Web 场景。
selectInheritedTags query 返回 inheritedTags 属性,其中包含位于 template/host/linked templates 上的标签。
templated boolean 如果设置为 true,则仅返回属于模板的 Web 场景。
templateids ID/array 仅返回属于给定模板的 Web 场景。
expandName flag 展开 Web 场景名称中的宏。
expandStepName flag 展开场景步骤名称中的宏。
evaltype integer 标签求值方法

可能的值:
0 - (默认) And/Or;
2 - Or。
tags array 仅返回具有给定标签的 Web 场景。
格式:[{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]
空数组将返回所有 Web 场景。

可能的operator 值:
0 - (默认) 包含;
1 - 等于;
2 - 不包含;
3 - 不等于;
4 - 存在;
5 - 不存在。
selectHosts query 以数组形式在 hosts 属性中返回该 Web 场景所属的主机。
selectSteps query steps 属性中返回 Web 场景步骤。

支持 count
selectTags query tags 属性中返回 Web 场景标签。
sortfield string/array 按给定属性对结果进行排序。

可能的值:httptestidname
countOutput boolean 这些参数在参考说明中进行了描述。
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

返回值

(integer/array) 返回以下之一:

  • 对象数组;
  • 如果使用了 countOutput 参数,则返回检索到的对象数量。

示例

检索一个 web 场景

检索 web 场景“9”的所有数据。

请求

{
    "jsonrpc": "2.0",
    "method": "httptest.get",
    "params": {
        "output": "extend",
        "selectSteps": "extend",
        "httptestids": "9"
    },
    "id": 1
}

响应:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "httptestid": "9",
            "name": "Homepage check",
            "delay": "1m",
            "status": "0",
            "agent": "Zabbix",
            "authentication": "0",
            "http_user": "",
            "http_password": "",
            "hostid": "10084",
            "templateid": "0",
            "http_proxy": "",
            "retries": "1",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "uuid": "",
            "headers": [],
            "variables": [],
            "steps": [
                {
                    "httpstepid": "36",
                    "httptestid": "9",
                    "name": "Homepage",
                    "no": "1",
                    "url": "http://example.com",
                    "timeout": "15s",
                    "posts": "",
                    "required": "",
                    "status_codes": "200",
                    "follow_redirects": "1",
                    "retrieve_mode": "0",
                    "post_type": "1",
                    "headers": [],
                    "variables": [
                        {
                            "name":"{var}",
                            "value":"12"
                        }
                    ],
                    "query_fields": []
                },
                {
                    "httpstepid": "37",
                    "httptestid": "9",
                    "name": "Homepage / About",
                    "no": "2",
                    "url": "http://example.com/about",
                    "timeout": "15s",
                    "posts": "",
                    "required": "",
                    "status_codes": "200",
                    "follow_redirects": "1",
                    "retrieve_mode": "0",
                    "post_type": "1",
                    "headers": [],
                    "variables": [],
                    "query_fields": []
                }
            ]
        }
    ],
    "id": 1
}

另请参阅

源码

ui/include/classes/api/services/CHttpTest.php 中的 CHttpTest::get()。