maintenance_create
Schedule maintenance periods in Zabbix by specifying start and end times, host or group IDs, and time periods. Streamline system updates and downtime management with JSON-formatted results.
Instructions
Create a new maintenance period in Zabbix.
Args:
name: Maintenance name
active_since: Start time (Unix timestamp)
active_till: End time (Unix timestamp)
groupids: List of host group IDs
hostids: List of host IDs
timeperiods: List of time periods
description: Maintenance description
Returns:
str: JSON formatted creation result
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| active_since | Yes | ||
| active_till | Yes | ||
| description | No | ||
| groupids | No | ||
| hostids | No | ||
| name | Yes | ||
| timeperiods | No |
Input Schema (JSON Schema)
{
"properties": {
"active_since": {
"title": "Active Since",
"type": "integer"
},
"active_till": {
"title": "Active Till",
"type": "integer"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Description"
},
"groupids": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Groupids"
},
"hostids": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Hostids"
},
"name": {
"title": "Name",
"type": "string"
},
"timeperiods": {
"anyOf": [
{
"items": {
"additionalProperties": true,
"type": "object"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Timeperiods"
}
},
"required": [
"name",
"active_since",
"active_till"
],
"type": "object"
}
Implementation Reference
- src/zabbix_mcp_server.py:1186-1226 (handler)The handler function for the 'maintenance_create' tool, decorated with @mcp.tool() for registration. It creates a new maintenance period using the Zabbix API, validates read-only mode, prepares parameters, calls client.maintenance.create, and formats the response.@mcp.tool() def maintenance_create(name: str, active_since: int, active_till: int, groupids: Optional[List[str]] = None, hostids: Optional[List[str]] = None, timeperiods: Optional[List[Dict[str, Any]]] = None, description: Optional[str] = None) -> str: """Create a new maintenance period in Zabbix. Args: name: Maintenance name active_since: Start time (Unix timestamp) active_till: End time (Unix timestamp) groupids: List of host group IDs hostids: List of host IDs timeperiods: List of time periods description: Maintenance description Returns: str: JSON formatted creation result """ validate_read_only() client = get_zabbix_client() params = { "name": name, "active_since": active_since, "active_till": active_till } if groupids: params["groupids"] = groupids if hostids: params["hostids"] = hostids if timeperiods: params["timeperiods"] = timeperiods if description: params["description"] = description result = client.maintenance.create(**params) return format_response(result)