task.create
Description
object task.create(object/array tasks)
This method allows to create tasks.
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/array) A task to create.
The method accepts tasks with the standard task properties.
Note that 'Execute now' tasks can be created only for the following types of items/discovery rules:
- Zabbix agent (passive)
- Simple check
- SNMP agent (v1/v2/v3)
- Zabbix internal
- External check
- Database monitor
- HTTP agent
- IPMI agent
- SSH agent
- TELNET agent
- JMX agent
- Calculated
- Dependent item
- Script
- Browser
If the item/discovery rule is of type "Dependent item", then its master item must also be one of the above types.
Return values
(object) Returns an object containing the IDs of the created tasks
under the taskids property. One task is created for each item and
low-level discovery rule. The order of the returned IDs matches the
order of the passed itemids.
Examples
Creating a task
Create an 'Execute now' task for an item and a low-level discovery rule.
{
"jsonrpc": "2.0",
"method": "task.create",
"params": [
{
"type": 6,
"request": {
"itemid": "10092"
}
},
{
"type": 6,
"request": {
"itemid": "10093"
}
}
],
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"taskids": [
"1",
"2"
]
},
"id": 1
}
Create a 'Refresh proxy configuration' task for two proxies.
{
"jsonrpc": "2.0",
"method": "task.create",
"params": [
{
"type": 2,
"request": {
"proxyids": ["10459", "10460"]
}
}
],
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"taskids": [
"1"
]
},
"id": 1
}
Create a 'Diagnostic information' task.
{
"jsonrpc": "2.0",
"method": "task.create",
"params": [
{
"type": 1,
"request": {
"alerting": {
"stats": [
"alerts"
],
"top": {
"media.alerts": 10
}
},
"lld": {
"stats": "extend",
"top": {
"values": 5
}
}
},
"proxyid": 0
}
],
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"taskids": [
"3"
]
},
"id": 1
}
See also
- Task
- 'Execute now' request object
- 'Refresh proxy configuration' request object
- 'Diagnostic information' request object
Source
CTask::create() in ui/include/classes/api/services/CTask.php.