task.create

描述

object task.create(object/array tasks)

此方法允许create新任务(例如收集诊断数据 或检查监控项或无需重新加载配置的低级发现规则)。

此方法仅适用于超级管理员用户类型。 调用该方法的权限可以在用户角色设置中撤销。参见 User roles 获取更多信息。

参数

(object/array) 一个用于create的任务.

该方法接受具有任务对象的任务.

请注意'立即执行'任务只能为以下类型的监控项/发现规则创建:

  • Zabbix agent
  • SNMPv1/v2/v3 agent
  • 简单检查
  • 内部检查
  • 外部检查
  • 数据库监控
  • HTTP agent
  • IPMI agent
  • SSH agent
  • TELNET agent
  • 计算检查
  • JMX agent
  • 依赖监控项

返回值

(object) 返回一个包含所创建任务ID的object 存储在taskids属性下。每个监控项和 低级发现规则都会创建一个任务。返回的ID顺序与 传入的itemids顺序相匹配。

示例

创建任务

为两个监控项创建任务Execute now。一个是监控项,另一个是低级发现规则。

执行请求:

{
    "jsonrpc": "2.0",
    "method": "task.create",
    "params": [
        {
            "type": 6,
            "request": {
                "itemid": "10092"
            }
        },
        {
            "type": 6,
            "request": {
                "itemid": "10093"
            }
        }
    ],
    "id": 1
}

响应:

{
    "jsonrpc": "2.0",
    "result": {
        "taskids": [
            "1",
            "2"
        ]
    },
    "id": 1
}

为两个proxies创建任务Refresh proxy configuration

执行请求:

{
    "jsonrpc": "2.0",
    "method": "task.create",
    "params": [
        {
            "type": 2,
            "request": {
                "proxyids": ["10459", "10460"]
            }
        }
    ],
    "id": 1
}

响应:

{
    "jsonrpc": "2.0",
    "result": {
        "taskids": [
            "1"
        ]
    },
    "id": 1
}

创建任务diagnostic information

执行请求:

{
    "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
}

响应:

{
    "jsonrpc": "2.0",
    "result": {
        "taskids": [
            "3"
        ]
    },
    "id": 1
}

另请参阅

来源

CTask::create() 位于 ui/include/classes/api/services/CTask.php 文件中.