0

我正在尝试设置对多个客户端的分布式 icinga 监控。

我已经根据需要设置了区域,即:

1)在主节点上它看起来像这样

object Zone "edge-dev" { 
  parent="master"
  endpoints=[ 
    "edge-dev-docker",
    "edge-dev-aws"
  ]
}

object Endpoint "edge-dev-docker" {}
object Endpoint "edge-dev-aws" {}
object Endpoint "icinga.master" {}

object Zone "master" {
  endpoints = [ "icinga.master" ]
}

常量.conf:

...
const NodeName = "icinga.master"

const ZoneName = "icinga.master"
...

2) 在每个客户端节点上:

object Endpoint "icinga.master" {
    host = "icinga.master"
    port = "5665"
}

object Zone "master" {
    endpoints = [ "icinga.master" ]
}

object Zone "global-templates" {
    global = true
}

object Zone "director-global" {
    global = true
}

object Endpoint NodeName {}

object Zone ZoneName {
    endpoints = [ NodeName ]
    parent = "master"
}

和常量.conf:

const NodeName = "edge-dev-docker"

const ZoneName = "edge-dev"

const NodeName = "edge-dev-aws"

const ZoneName = "edge-dev"

对于每个节点

现在,我正在尝试对每个客户端节点上的 squid 进程进行一些监控:

curl -k -s -u user:pass -H 'Accept: application/json' -X PUT 'https://$ICINGA_HOST:$ICINGA_PORT/v1/objects/checkcommands/check_process' -d '{ "templates": [ "plugin-check-command" ], "attrs": { "command": [ "/usr/lib/nagios/plugins/check_procs" ], "arguments": { "--ereg-argument-array": "$process_regex$", "-c": "$range$" }, "vars.process_regex": "", "vars.range": "1:1", "zone": "edge-dev" } }'  | python -m json.tool

curl -k -s -u user:pass -H 'Accept: application/json' -X PUT 'https://$ICINGA_HOST:$ICINGA_PORT/v1/objects/hosts/edge-dev-ip-docker' -d '{ "templates": [ "generic-host" ], "attrs": { "address": "ip-docker", "check_command": "ssh", "vars.os" : "Linux", "zone": "edge-dev" } }' | python -m json.tool

curl -k -s -u user:pass -H 'Accept: application/json' -X PUT 'https://$ICINGA_HOST:$ICINGA_PORT/v1/objects/hosts/edge-dev-ip-aws' -d '{ "templates": [ "generic-host" ], "attrs": { "address": "ip-aws", "check_command": "ssh", "vars.os" : "Linux", "zone": "edge-dev" } }' | python -m json.tool

curl -k -s -u user:pass -H 'Accept: application/json' -X PUT 'https://$ICINGA_HOST:$ICINGA_PORT/v1/objects/services/edge-dev-ip-aws!edge-dev-ip-aws-squid' -d '{ "templates": [ "generic-service" ], "attrs": { "check_command": "check_process", "vars.process_regex": "'/usr/sbin/squid'", "vars.range": "1:2", "check_interval": 30,"retry_interval": 30, "max_check_attempts": 3, "zone": "edge-dev" } }'  | python -m json.tool

curl -k -s -u user:pass -H 'Accept: application/json' -X PUT 'https://$ICINGA_HOST:$ICINGA_PORT/v1/objects/services/edge-dev-ip-docker!edge-dev-ip-docker-squid' -d '{ "templates": [ "generic-service" ], "attrs": { "check_command": "check_process", "vars.process_regex": "'/usr/sbin/squid'", "vars.range": "1:2", "check_interval": 30,"retry_interval": 30, "max_check_attempts": 3, "zone": "edge-dev" } }'  | python -m json.tool

所有对象都很好地传播到客户端节点。问题是,现在每个客户端都执行这两种服务(即使不是“他的”服务,即“拥有”服务的主机也不是唯一运行它的主机)。

为了使问题更清楚 - 现在edge-dev-ip-aws主机和edge-dev-ip-docker主机都运行这两个服务edge-dev-ip-docker!edge-dev-ip-docker-squidedge-dev-ip-aws!edge-dev-ip-docker-aws

我怎样才能让每个人只运行它自己的服务?

任何帮助或提示将不胜感激:)

4

1 回答 1

1

您的 zone.conf 应该在所有服务器上都相同。就像是

object Endpoint "icinga.master" {
        host = "<IP>"
}
object Endpoint "edge-dev-docker" {
        host = "<IP>"
}
object Endpoint "edge-dev-aws" {
        host = "<IP>"
}
object Zone "icinga.master" {
        endpoints = [ "icinga.master" ]
}
object Zone "edge-dev" {
        endpoints = [ "edge-dev-docker", "edge-dev-aws" ]
        parent = "icinga.master"
}
/*
 * Global zone for templates
 */
object Zone "global-templates" {
        global = true
}
object Zone "director-global" {
        global = true
}

由于两者edge-dev-docker,edge-dev-aws都在同一个集群中,因此它们都可以进行检查。因此,如果edge-dev-aws不正常运行edge-dev-docker就会这样做。如果您希望它们各自分开,则它们将需要自己的区域,例如:

object Endpoint "icinga.master" {
        host = "<IP>"
}
object Endpoint "edge-dev-docker" {
        host = "<IP>"
}
object Endpoint "edge-dev-aws" {
        host = "<IP>"
}
object Zone "icinga.master" {
        endpoints = [ "icinga.master" ]
}
object Zone "edge-dev-docker" {
        endpoints = [ "edge-dev-docker" ]
        parent = "icinga.master"
}
object Zone "edge-dev-aws" {
        endpoints = [ "edge-dev-aws" ]
        parent = "icinga.master"
}
/*
 * Global zone for templates
 */
object Zone "global-templates" {
        global = true
}
object Zone "director-global" {
        global = true
}
于 2018-02-14T19:15:42.277 回答