Zabbix Documentation 1.8

2.23.03.23.4In development:4.0Unsupported versions:1.82.02.4

User Tools

Site Tools


Sidebar

api:maintenance:create

create()

This method allows you to create a maintenance as defined by the maintenance data array.

Parameters

ParameterTypeOptionalDescriptionDetails
maintenance dataarray or object No Array of Maintenance objects or a single objectmaintenanceid shouldn't be specified
groupidsarrayNo Host group ids
hostidsarrayNo Host ids

Returns

ParameterDescription
resultOperation successful. Result will contain array of created Maintenance IDs. maintenanceid are assigned to each Maintenance object
errorIn case of any errors

Examples

simple create

{
"jsonrpc":"2.0",
"method":"maintenance.create",
"params":[{
    "groupids":[],
    "hostids":["100100000010229"],
    "name":"ZABBIX Servers",
    "maintenance_type":"0",
    "description":"",
    "active_since":"1276163035",
    "active_till":"1307698980"
}],
"auth":"038e1d7b1735c6a5436ee9eae095879e",
"id":3
}

Maintenance added successfully:

{
"jsonrpc":"2.0",
"result":{
   "maintenanceids": ["100100000000005"]
},
"id":3
}

Maintenance already exists:

{
"jsonrpc":"2.0",
"error":{
      "code":-32602,
      "message":"Invalid params.",
      "data":"[ CMaintenance::create ] Maintenance [ ZABBIX Servers ] already exists"
},
"id":3
}

create maintenance with onetime period

{
    "groupids": [
        14
    ],
    "name": "T1",
    "maintenance_type": 0,
    "description": "",
    "active_since": "1276163035",
    "active_till": "1307698980",
    "timeperiods": [
        {
            "timeperiod_type": 0,
            "start_date": "1307689239",
            "period": 7200
        }
    ]
}

create maintenance with daily period (at 11:00 every five days for 6 hours 2 minutes)

{
    "groupids": [
        14
    ],
    "name": "T2",
    "maintenance_type": 0,
    "description": "",
    "active_since": "1276163035",
    "active_till": "1307698980",
    "timeperiods": [
        {
            "timeperiod_type": 2,
            "start_time": 39600,
            "period": 21720,
            "every": 5
        }
    ]
}

create maintenance with weekly period (at 11:00 on Monday and Tuesday of every second week for 6 hours 2 minutes)

{
    "groupids": [
        14
    ],
    "name": "T3",
    "maintenance_type": 0,
    "description": "",
    "active_since": "1276163035",
    "active_till": "1307698980",
    "timeperiods": [
        {
            "timeperiod_type": 3,
            "start_time": 39600,
            "period": 21720,
            "every": 2,
            "dayofweek": 3
        }
    ]
}

create maintenance with monthly period (at 10:00 on every second week Monday and Wednesday of every January and March for 2 hours)

{
    "groupids": [
        14
    ],
    "name": "T4",
    "maintenance_type": 0,
    "description": "",
    "active_since": "1276163035",
    "active_till": "1307698980",
    "timeperiods": [
        {
            "timeperiod_type": 4,
            "start_time": 36000,
            "period": 7200,
            "every": 2,
            "dayofweek": 5,
            "month": 5,
            "day": 0
        }
    ]
}