创建
Description 说明
object task.create(object **task**)
This method allows to create new task. 该方法允许创建新的任务。
Parameters 参数
(object)
A task to create. (object)
需要创建的任务。 The method accepts the following parameters. 此方法接受以下参数。
Parameter 参数 | Type 类型 | Description 说明 |
---|---|---|
type (required 必须) | integer 整数型 | Task type. 任务类型。 Possible values: 许可值: 6 - Check now. 正在核实。 |
itemids (required 必须) | string/array 字符串/数组 | IDs of items and low-level discovery rules. 监控项和低级别发现规则的ID。 Item or discovery rule must of the following type: 监控项或自动发现规则必须是以下类型: 0 - Zabbix agent; Zabbix agent; 1 - SNMPv1 agent; SNMPv1客户端; 3 - simple check; 简单检查; 4 - SNMPv2 agent; SNMPv2客户端; 5 - Zabbix internal; Zabbix内部; 6 - SNMPv3 agent; SNMPv3客户端; 8 - Zabbix aggregate; Zabbix整合; 10 - external check; 外部检查; 11 - database monitor; 数据库监控; 12 - IPMI agent; IPMI客户端; 13 - SSH agent; SSH客户端; 14 - TELNET agent; TELNET客户端; 15 - calculated; 计算项; 16 - JMX agent. JMX客户端。 |
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
. (object)
返回一个对象,该对象包含在taskids
属性中已创建任务的ID。为每个监控项和低级别发现规则创建的任务,返回ID的顺序与传递itemids
的顺序相匹配。
Examples 范例
Creating a task 创建任务
Create a task check now
for two items. One is an item, the other is a low-level discovery rule. 为两个项目,其中一个是监控项,另外一个低级别发现规则,创建一个check now
任务。
Request 请求:
{
"jsonrpc": "2.0",
"method": "task.create",
"params": {
"type": "6",
"itemids": ["10092", "10093"],
},
"auth": "700ca65537074ec963db7efabda78259",
"id": 1
}
Response 响应:
{
"jsonrpc": "2.0",
"result": {
"taskids": [
"1",
"2"
]
},
"id": 1
}
Source 源码
CTask::create() in frontends/php/include/classes/api/services/CTask.php. CTask::create()方法可在frontends/php/include/classes/api/services/CTask.php中参考。