2022 Zabbix中国峰会
2022 Zabbix中国峰会

模块.获取

描述

integer/array module.get(object parameters)

此方法允许根据给定参数检索模块。

此方法适用于任何类型的用户。可以在用户角色设置中撤销调用该方法的权限。 参阅 用户角色了解更多信息。

参数

(object) 定义期望输出的参数。

此方法支持以下参数。

参数 类型 描述
moduleids ID/array 仅返回具有给定 ID 的模块。
sortfield string/array 按给定属性对结果进行排序。

可能的值: moduleid, relative_path.
countOutput boolean 这些参数对所有的 get 方法是通用的,详情请参阅 参考说明 页面。
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

返回值

(integer/array) 返回两者其中任一:

  • 一组对象数组;
  • 如果已经使用了 countOutput 参数,则检索对象的计数。

示例

通过 ID 检索模块

检索有关模块 "1"、 "2"和 "25"的所有数据。

请求

{
           "jsonrpc": "2.0",
           "method": "module.get",
           "params": {
               "output": "extend",
               "moduleids": [
                   "1",
                   "2",
                   "25"
               ]
           },
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "moduleid": "1",
                   "id": "actionlog",
                   "relative_path": "widgets/actionlog",
                   "status": "1",
                   "config": []
               },
               {
                   "moduleid": "2",
                   "id": "clock",
                   "relative_path": "widgets/clock",
                   "status": "1",
                   "config": []
               },
               {
                   "moduleid": "25",
                   "id": "example",
                   "relative_path": "modules/example_module",
                   "status": "1",
                   "config": []
               }
           ],
           "id": 1
       }

另请参阅

来源

CModule::get() in ui/include/classes/api/services/CModule.php