integer/array httptest.get(object parameters)
该方法允许根据给定的参数检索Web场景。
此方法可供任何类型的用户使用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参见 User roles。
(object)
定义期望输出的参数。
该方法支持以下参数。
参数 | 数据类型 | 描述 |
---|---|---|
groupids | ID/array | 仅返回属于指定 主机 组的 Web 场景。 |
hostids | ID/array | 仅返回属于指定 主机 的 Web 场景。 |
httptestids | ID/array | 仅返回具有指定 ID 的 Web 场景。 |
inherited | boolean | 如果设置为 true ,则仅返回从模板继承的 Web 场景。 |
monitored | boolean | 如果设置为 true ,则仅返回属于被监控 主机 的已启用 Web 场景。 |
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>"}, ...] 。空的 array 将返回所有 Web 场景。 可能的操作符类型: 0 - (默认)Like; 1 - Equal; 2 - Not like; 3 - Not equal; 4 - Exists; 5 - Not exists。 |
selectHosts | query | 将 Web 场景所属的 主机 作为 array 返回到 hosts 属性中。 |
selectSteps | query | 在 steps 属性中返回 Web 场景步骤。支持 count 。 |
selectTags | query | 在 tags 属性中返回 Web 场景标签。 |
sortfield | string/array | 按指定属性对结果进行排序。 可能的值: httptestid 、name 。 |
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)
返回以下之一:
countOutput
参数,则为检索到的 objects 的数量。检索有关Web场景"4"的所有数据。
执行请求:
{
"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",
"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 中。