Zabbix Documentation 4.0

2.23.04.04.2 (current)In development:4.4 (devel)Unsupported:1.82.02.43.23.4

User Tools

Site Tools


Sidebar

zh:manual:api:reference:maintenance:get

maintenance.get

Description 说明

integer/array maintenance.get(object parameters)

The method allows to retrieve maintenances according to the given parameters. 此方法用于根据给定参数获取维护模式。

Parameters 参数

(object) Parameters defining the desired output. (object) 定义期望输出的参数。

The method supports the following parameters. 此方法支持如下参数。

Parameter Type Description
groupids string/array Return only maintenances that are assigned to the given host groups. 仅返回指定到给定主机组的维护模式。
hostids string/array Return only maintenances that are assigned to the given hosts. 仅返回指定到给定主机的维护模式。
maintenanceids string/array Return only maintenances with the given IDs. 仅返回给定IDs的维护模式。
selectGroups query Return host groups assigned to the maintenance in the groups property. 在group属性中返回维护模式所指定的主机组。
selectHosts query Return hosts assigned to the maintenance in the hosts property. 在host属性中返回维护模式所指定的主机。
selectTimeperiods query Return the maintenance's time periods in the timeperiods property. 在timeperiods属性中返回维护模式的时间周期。
sortfield string/array Sort the result by the given properties. 根据给定的属性记性排序。

Possible values are: maintenanceid, name and maintenance_type. 可能的值有:, name and maintenance_type
countOutput booleanThese parameters being common for all get methods are described in detail in the reference commentary. 这些参数在reference commentary中详细描述的所有get方法是通用的。
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

Return values

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

Examples 示例

Retrieving maintenances 获取维护模式

Retrieve all configured maintenances, and the data about the assigned host groups, hosts and defined time periods. 获取所有配置的维护模式,以及关于指定主机组、主机和定义的时间周期数据。

Request:

{
    "jsonrpc": "2.0",
    "method": "maintenance.get",
    "params": {
        "output": "extend",
        "selectGroups": "extend",
        "selectTimeperiods": "extend"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "maintenanceid": "3",
            "name": "Sunday maintenance",
            "maintenance_type": "0",
            "description": "",
            "active_since": "1358844540",
            "active_till": "1390466940",
            "groups": [
                {
                    "groupid": "4",
                    "name": "Zabbix servers",
                    "internal": "0"
                }
            ],
            "timeperiods": [
                {
                    "timeperiodid": "4",
                    "timeperiod_type": "3",
                    "every": "1",
                    "month": "0",
                    "dayofweek": "1",
                    "day": "0",
                    "start_time": "64800",
                    "period": "3600",
                    "start_date": "2147483647"
                }
            ]
        }
    ],
    "id": 1
}

See also

Source

CMaintenance::get() in frontends/php/include/classes/api/services/CMaintenance.php.