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

service.adddependencies

Description说明

object service.adddependencies(object/array serviceDependencies)

This method allows to create dependencies between services此方法允许创建服务之间的依赖关系.

Parameters参数

(object/array) Service dependencies to create创建服务依赖关系.

Each service dependency has the following parameters每个服务依赖项具有以下参数.

Parameter参数 T pe类型 Des ription说明
serviceid string ID of the service that depends on a service, that is, the parent service.取决于服务的服务ID,即父服务
dependsOnServiceid string ID of the service that a service depends on, that is, the child service.服务所依赖的服务ID,即子服务
soft string Type of dependency依赖类型.

Refer to the service dependency object page for more information on dependency types.有关依赖关系类型的更多信息,请参阅service dependency object page

Return values返回值

(object) Returns an object containing the IDs of the affected parent services under the serviceids property. (object)返回一个包含serviceids属性下的受影响的父服务的ID的对象。

Examples范例

Creating a hard dependency创造强依赖

Make service "2" a hard-dependent child of service "3"使服务"2"成为服务"3"的强依赖的子服务.

Request请求:

{
           "jsonrpc": "2.0",
           "method": "service.adddependencies",
           "params": {
               "serviceid": "3",
               "dependsOnServiceid": "2",
               "soft": 0
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response响应:

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

See also参考

Source源码

CService::addDependencies() in frontends/php/include/classes/api/services/CService.php.