这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

创建

说明

object task.create(object task)

该方法允许创建新的任务。

参数

(object)需要创建的任务。 此方法接受以下参数。

参数 类 说明
type
(必须)
整数型 任务
型。
许可值:
6 - 正在核实。
itemids
(必须)
字符串/数组 监控项和
级别发现规则的ID。
监控项或自动发现规则必须是以下类型:
0 - Zabbix agent;
1 - SNMPv1客户端;
3 - 简单检查;
4 - SNMPv2客户端;
5 - Zabbix内部;
6 - SNMPv3客户端;
8 - Zabbix整合;
10 - 外部检查;
11 - 数据库监控;
12 - IPMI客户端;
13 - SSH客户端;
14 - TELNET客户端;
15 - 计算项;
16 - 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中参考。

Source

CTask::create() in ui/include/classes/api/services/CTask.php.