maintenance.get
Description
integer/array maintenance.get(object parameters)
The method allows you to retrieve maintenances according to the given parameters.
This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.
Parameters
(object) Parameters defining the desired output.
The method supports the following parameters.
| Parameter | Type | Description |
|---|---|---|
| groupids | ID/array | Return only maintenances that are assigned to the given host groups. |
| hostids | ID/array | Return only maintenances that are assigned to the given hosts. |
| triggerids | ID/array | Return only maintenances that are assigned to the given triggers. |
| maintenanceids | ID/array | Return only maintenances with the given IDs. |
| selectHostGroups | query | Return a hostgroups property with host groups assigned to the maintenance. |
| selectHosts | query | Return a hosts property with hosts assigned to the maintenance. |
| selectTriggers | query | Return a triggers property with triggers assigned to the maintenance. |
| selectEventNames | query | Return an event_names proper,ty with event names assigned to the maintenance. |
| selectTags | query | Return a tags property with problem tags of the maintenance. |
| selectTimeperiods | query | Return a timeperiods property with time periods of the maintenance. |
| sortfield | string/array | Sort the result by the given properties. Possible values: maintenanceid, name, maintenance_type, active_since, active_till. |
| countOutput | boolean | These parameters are described in the reference commentary. |
| 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
countOutputparameter has been used.
Examples
Retrieving maintenances
Retrieve all configured maintenances, the data about the assigned maintenance scope (host group, host, trigger, event name, tags), and defined time periods.
{
"jsonrpc": "2.0",
"method": "maintenance.get",
"params": {
"output": "extend",
"selectHostGroups": "extend",
"selectHosts": "extend",
"selectTriggers": "extend",
"selectEventNames": "extend",
"selectTags": "extend",
"selectTimeperiods": "extend"
},
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": [
{
"maintenanceid": "1",
"name": "Regular DB maintenance",
"maintenance_type": "0",
"description": "",
"active_since": "1791936000",
"active_till": "2107555200",
"tags_evaltype": "0",
"hostgroups": [
{
"groupid": "20",
"name": "Databases",
"flags": "0",
"uuid": "748ad4d098d447d492bb935c907f652f"
}
],
"triggers": [],
"event_names": [],
"hosts": [],
"tags": [],
"timeperiods": [
{
"timeperiod_type": "4",
"every": "1",
"month": "4095",
"dayofweek": "0",
"day": "1",
"start_time": "64800",
"period": "3600",
"start_date": "0"
}
]
},
{
"maintenanceid": "2",
"name": "Ad-hoc: Printer: ink OUT",
"maintenance_type": "0",
"description": "",
"active_since": "1792057740",
"active_till": "1792061340",
"tags_evaltype": "0",
"hostgroups": [
{
"groupid": "4",
"name": "Zabbix servers",
"flags": "0",
"uuid": "6f6799aa69e844b4b3918f779f2abf08"
}
],
"triggers": [],
"event_names": [
{
"operator": "2",
"value": "Printer: ink OUT"
}
],
"hosts": [],
"tags": [],
"timeperiods": [
{
"timeperiod_type": "0",
"every": "1",
"month": "0",
"dayofweek": "0",
"day": "0",
"start_time": "0",
"period": "3600",
"start_date": "1792057740"
}
]
}
],
"id": 1
}```
[comment]: # ({/ec7146e4-0b1cb387})
[comment]: # ({0c4dce96-dbcf678a})
### See also
- [Host](/manual/api/reference/host/object#host)
- [Host group](/manual/api/reference/hostgroup/object#host-group)
- [Trigger](/manual/api/reference/trigger/object#trigger)
- [Event name](object#event-name)
- [Problem tag](object#problem-tag)
- [Time period](object#time-period)
[comment]: # ({/0c4dce96-dbcf678a})
[comment]: # ({f0ec3c40-50ed5be3})
### Source
CMaintenance::get() in *ui/include/classes/api/services/CMaintenance.php*.
[comment]: # ({/f0ec3c40-50ed5be3})