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

创建服务

描述

object service.create(object/array services)

此方法允许创建新服务。

此方法允许任何用户使用。可以在用户角色设置中撤销调用此方法的权限。更多信息请查看用户角色

Parameters 参数

(object/array) services to create. (object/array)创建服务。

Additionally to the standard service properties, the method accepts the following parameters. 除standard service properties之外,该方法接受以下参数。

Parameter 参数 T pe 类型 Des ription 说明
dependencies array 数组 S rvice dependencies. 服务依赖。

Each service dependency has the following parameters: 每个服务依赖项具有以下参数:
- dependsOnServiceid - (string 字符串) ID of an service the service depends on, that is, the child service. 被子服务依赖的服务ID。
- soft - (integer 整数型) type of service dependency; refer to the service dependency object page for more information on dependency types. 有关依赖关系类型的更多信息,请参阅service dependency object page
parentid string 字符串 ID of a hard-linked parent service. 硬链接的父服务的ID。
times array 数组 S rvice times to be created for the service. 为服务创建的服务时间。

返回值

(对象) 返回一个serviceids属性包含被创建服务ID的对象。返回的ID顺序与传入服务的顺序一致。

示例

Creating an service 创建服务

Create an service that will be switched to problem state, if at least one child has a problem. SLA calculation will be on and the minimum acceptable SLA is 99.99%. 创建一个至少有一个子服务有问题,将被切换到问题状态的服务。SLA计算将打开并且SLA最低可接受99.99%。 Request 请求:

{
           "jsonrpc": "2.0",
           "method": "service.create",
           "params": {
               "name": "Server 1",
               "algorithm": 1,
               "showsla": 1,
               "goodsla": 99.99,
               "sortorder": 1
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response 响应:

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

来源

CService::create() 在 frontends/php/include/classes/api/services/CService.php