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

service.update

更新服务

Description

描述

object service.update(object/array services)

This method allows to update existing 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) service properties to be updated. (object/array)需要更新的服务属性。 The serviceid property must be defined for each service, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged. 必须为每个服务定义serviceid属性,所有其他属性为可选项。只有通过的属性会被更新,所有其他属性将保持不变。 Additionally to the standard service properties, the method accepts the following parameters. 除standard service properties之外,该方法接受以下参数。 |Parameter参数|Type类型| Description描述| |--|--|------| |children|array|Child services to replace the current child services.子服务取代当前的子服务

The child services must have only the serviceid property defined.子服务必须有唯一的serviceid属性。| |parents|array|Parent services to replace the current parent services.父服务取代当前的父服务

The parent services must have only the serviceid property defined.父服务必须有唯一的serviceid属性。| |tags|array|Service tags to replace the current service tags.服务标签以替换当前服务标签。| |problem_tags|array|Problem tags to replace the current problem tags.问题标签以替换当前问题标签。| |status_rules|array|Status rules to replace the current status rules.状态规则以替换当前状态规则。|

Return values

返回值

(object) Returns an object containing the IDs of the updated services under the serviceids property. (对象) 返回一个serviceids属性包含了被更新服务ID的对象。

Examples

示例

Setting the parent for a service

设置服务的父服务

Make service with ID "3" to be the parent for service with ID "5". 使ID为“3”的服务成为ID为“5”的服务的父服务。 Request: 请求:

{
           "jsonrpc": "2.0",
           "method": "service.update",
           "params": {
               "serviceid": "5",
               "parents": [
                   {
                       "serviceid": "3"
                   }
               ]
           },
           "id": 1
       }

Response: 响应:

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

Adding a scheduled downtime

增加关机计划

Add a downtime for service with ID "4" scheduled weekly from Monday 22:00 till Tuesday 10:00. 给ID为“4”的服务增加每周一22:00到周二10:00的关机计划。 Request: 请求:

{
           "jsonrpc": "2.0",
           "method": "service.update",
           "params": {
               "serviceid": "4",
               "times": [
                   {
                       "type": "1",
                       "ts_from": "165600",
                       "ts_to": "201600"
                   }
               ]
           },
           "id": 1
       }

Response: 响应:

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

Source

来源

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