2022 Zabbix中国峰会
2022 Zabbix中国峰会

service.create

创建服务

Description

描述

object service.create(object/array services)

This method allows to create new services. 此方法允许创建新服务。 ::: noteclassic 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) services to create. (object/array)创建服务。 Additionally to the standard service properties, the method accepts the following parameters. 除standard service properties之外,该方法接受以下参数。

Parameter参数 Type类型 Description描述
children array Child services to be linked to the service.连接到子服务

The child services must have only the serviceid property defined.子服务必须仅定义唯一的serviceid属性。
parents array Parent services to be linked to the service.连接到父服务

The parent services must have only the serviceid property defined.父服务必须仅定义唯一的serviceid属性。
tags array Service tags to be created for the service.创建服务标签
problem_tags array Problem tags to be created for the service.创建问题标记
status_rules array Status rules to be created for the service.创建状态规则

Return values

返回值

(object) Returns an object containing the IDs of the created services under the serviceids property. The order of the returned IDs matches (对象) 返回一个serviceids属性包含被创建服务ID的对象。返回的ID顺序与传入服务的顺序一致。 the order of the passed services.

Examples

示例

Creating a service

创建服务

Create a service that will be switched to problem state, if at least one child has a problem. 创建将切换到问题状态的服务(如果至少有)子服务问题。 Request: 请求:

{
           "jsonrpc": "2.0",
           "method": "service.create",
           "params": {
               "name": "Server 1",
               "algorithm": 1,
               "sortorder": 1
           },
           "id": 1
       }

Response: 响应:

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

Source

来源

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