httptest.get

描述

integer/array httptest.get(object parameters)

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

此方法可供任何类型的用户使用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参阅User roles

参数

(object) 定义输出结果的参数

该方法支持以下参数

参数 数据类型 描述
groupids string/array 仅返回属于指定主机组的Web场景
hostids string/array 仅返回属于指定主机的Web场景
httptestids string/array 仅返回具有指定ID的Web场景
inherited boolean 若设为true则仅返回从模板继承的Web场景
monitored boolean 若设为true则仅返回属于受监控主机的启用Web场景
templated boolean 若设为true则仅返回属于模板的Web场景
templateids string/array 仅返回属于指定模板的Web场景
expandName flag 在Web场景名称中展开宏
expandStepName flag 在场景步骤名称中展开宏
evaltype integer 标签搜索规则

可选值:
0 - (默认) 与/或;
2 - 或
tags array of objects 仅返回具有指定标签的Web场景。根据操作符值对标签值进行精确匹配或大小写敏感/不敏感搜索
格式:[{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]
空array将返回所有Web场景

支持的操作符类型:
0 - (默认) 相似;
1 - 等于;
2 - 不相似;
3 - 不等于
4 - 存在;
5 - 不存在
selectHosts query hosts属性中以array形式返回Web场景所属的主机
selectSteps query 场景步骤属性中返回Web场景步骤

支持count
selectTags query web-场景标签属性中返回Web场景标签
sortfield string/array 按指定属性排序结果

可选值为:httptestidname
countOutput boolean 这些参数在通用get方法参数中有详细说明
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) 返回以下两种结果之一:

  • 一个包含objects的array;
  • 若使用了countOutput参数,则返回检索到的objects数量。

示例

获取 Web 场景

获取关于Web场景"4"的所有数据。

请求:

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

响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "httptestid": "9",
                   "name": "Homepage check",
                   "nextcheck": "0",
                   "delay": "1m",
                   "status": "0",
                   "variables": [],
                   "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",
                   "headers": [],
                   "steps": [
                       {
                           "httpstepid": "36",
                           "httptestid": "9",
                           "name": "Homepage",
                           "no": "1",
                           "url": "http://example.com",
                           "timeout": "15s",
                           "posts": "",
                           "required": "",
                           "status_codes": "200",
                           "variables": [  
                               {  
                                   "name":"{var}",
                                   "value":"12"
                               }
                           ],
                           "follow_redirects": "1",
                           "retrieve_mode": "0",
                           "headers": [],
                           "query_fields": []
                       },
                       {
                           "httpstepid": "37",
                           "httptestid": "9",
                           "name": "Homepage / About",
                           "no": "2",
                           "url": "http://example.com/about",
                           "timeout": "15s",
                           "posts": "",
                           "required": "",
                           "status_codes": "200",
                           "variables": [],
                           "follow_redirects": "1",
                           "retrieve_mode": "0",
                           "headers": [],
                           "query_fields": []
                       }
                   ]
               }
           ],
           "id": 1
       }

另请参阅

来源

CHttpTest::get() 位于 ui/include/classes/api/services/CHttpTest.php 文件中。