我正在尝试设置多组客户端的分布式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" ]
}
constants.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"
}
和constants.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-squid
和edge-dev-ip-aws!edge-dev-ip-docker-aws
如何让每个人只运行自己的服务?
任何帮助或提示都将不胜感激:)
答案 0 :(得分:1)
您的zones.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
都在同一个cluster,因此他们都可以进行检查。因此,如果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
}