Icinga2 分布式监控 - 端点 运行 其区域中的所有服务
Icinga2 distributed monitoring - Endpoint running all the services in it's zone
我正在尝试设置多个客户端的分布式 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
所有对象都很好地传播到客户端节点。
问题是,现在每个客户端都执行这两个服务(即使是那些不是 "his" 的服务,即 "owns" 服务不是唯一一个 运行 的主机) .
为了使问题更清楚-现在 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
如何让每个 运行 都只有自己的服务?
如有任何帮助或提示,我们将不胜感激:)
您的 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
}
我正在尝试设置多个客户端的分布式 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
所有对象都很好地传播到客户端节点。 问题是,现在每个客户端都执行这两个服务(即使是那些不是 "his" 的服务,即 "owns" 服务不是唯一一个 运行 的主机) .
为了使问题更清楚-现在 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
如何让每个 运行 都只有自己的服务?
如有任何帮助或提示,我们将不胜感激:)
您的 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
}