简体   繁体   English

设置容器化的Sensu服务器和客户端以监视Docker时出错

[英]Error Setting up Containerized Sensu-server and client, to monitor Docker

I am trying to setup sensu-server to monitor my docker containers, by following the instructions on this post. 我正在按照这篇文章上的说明尝试设置sensu-server来监视我的docker容器。

The Docker daemon is running on the same host has the sensu-server and sensu-clients (localhost). Docker守护程序在具有sensu-server和sensu-clients(localhost)的同一主机上运行。

The file check-docker, contains an entry to call the script load-docker-metrics.sh 文件check-docker,包含一个调用脚本load-docker-metrics.sh的条目。

check-docker.sh 检查docker.sh

{
  "checks": {
    "load_docker_metrics": {
      "type": "metric",
      "command": "load-docker-metrics.sh",
      "subscribers": [
        "docker"
      ],
      "interval": 10
    }
  }
}

load-docker-metrics.sh load-docker-metrics.sh

#!/bin/bash
set -e

# Count all running containers
running_containers=$(echo -e "GET /containers/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock \
    | tail -n +5                                                           \
    | python -m json.tool                                                  \
    | grep \"Id\"                                                          \
    | wc -l)
# Count all containers
total_containers=$(echo -e "GET /containers/json?all=1 HTTP/1.0\r\n" | nc -U /var/run/docker.sock \
 | tail -n +5 \
 | python -m json.tool \
 | grep \"Id\" \
 | wc -l)

# Count all images
total_images=$(echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock \
 | tail -n +5 \
 | python -m json.tool \
 | grep \"Id\" \
 | wc -l)

echo "docker.invismac.running_containers ${running_containers}"
echo "docker.invismac.total_containers ${total_containers}"
echo "docker.invismac.total_images ${total_images}"

if [ ${running_containers} -lt 3 ]; then
    exit 1;
fi

load-docker-metrics is basically making some calls to the docker api, and retrieving a few metrics. load-docker-metrics基本上是对docker api进行一些调用,并检索一些指标。 If I run this script on my host (invismac), it gives me an accurate result: 如果我在主机(invismac)上运行此脚本,它将为我提供准确的结果:

docker.invismac.running_containers 7
docker.invismac.total_containers 8
docker.invismac.total_images 15

I am launching the sensu-server container, with this command: 我使用以下命令启动sensu-server容器:

docker run -d --name sensu-server \\ -p 3000:3000 \\ -p 4567:4567 \\ -p 5671:5671 \\ -p 15672:15672 \\ -v $PWD/check-docker.json:/etc/sensu/conf.d/check-docker.json \\ hiroakis/docker-sensu-server docker run -d --name sensu-server \\ -p 3000:3000 \\ -p 4567:4567 \\ -p 5671:5671 \\ -p 15672:15672 \\ -v $ PWD / check-docker.json:/ etc / sensu /conf.d/check-docker.json \\ hiroakis / docker-sensu-server

After this, I can correctly access the uchima dashboard, at port 3000 之后,我可以正确访问uchima仪表板,端口3000

Then I launch the client, with this command: 然后,使用以下命令启动客户端:

docker run --name sensu-client --privileged \\ -v $PWD/load-docker-metrics.sh:/etc/sensu/plugins/load-docker-metrics.sh \\ -v /var/run/docker.sock:/var/run/docker.sock \\ usman/sensu-client localhost sensu password CLIENT-1 localhost docker run --name sensu-client --privileged \\ -v $ PWD / load-docker-metrics.sh:/etc/sensu/plugins/load-docker-metrics.sh \\ -v /var/run/docker.sock :/var/run/docker.sock \\ usman / sensu-client localhost sensu密码CLIENT-1 localhost

The client is suppose to communicate with RabbitMQ, and register itself in uchima, but nothing happens. 客户端应该与RabbitMQ进行通信,并在uchima中注册自己,但没有任何反应。 I have entered the container that runs the client, and by looking at the log, there seems to be an error with rabbitMQ: 我进入了运行客户端的容器,通过查看日志,rabbitMQ似乎出现错误:

"timestamp":"2016-04-15T15:18:50.768594+0000","level":"error","message":"[amqp] Detected TCP connection failure"} “ timestamp”:“ 2016-04-15T15:18:50.768594 + 0000”,“ level”:“错误”,“ message”:“ [amqp]检测到TCP连接失败”}

Rabbitmq is running, and I can access to its endpoint here: Rabbitmq正在运行,我可以在这里访问其端点:

http://localhost:15672 http:// localhost:15672

The dashboard gives me some information: I have 2 connections, 2 channels, 2 users. 仪表板向我提供了一些信息:我有2个连接,2个通道,2个用户。

Also, if I go to the sensu-master container, I can check that rabbitmq has this user: 另外,如果我转到sensu-master容器,则可以检查Rabbitmq是否具有该用户:

sensu [administrator] sensu [管理员]

With all permissions: 具有所有权限:

/sensu .* .* .* / sensu。*。*。*

Any ideas why the sensu-client is not able to communicate with RabbitMQ? 有任何想法为何sensu客户端无法与RabbitMQ通信? Some other check that I could try? 我可以尝试其他检查吗? Am I passing some wrong values on the configuration of the server or the client? 我在服务器或客户端的配置上传递了一些错误的值吗? is it not possible to have server and client in the same host? 服务器和客户端不能在同一主机中?

Dmesg on the client, also gives me this message (I don't know if it could be related) 客户端上的dmesg也给我此消息(我不知道它是否可能相关)

[29252.322147] audit: type=1400 audit(1460734746.650:975): apparmor="DENIED" operation="ptrace" profile="docker-default" pid=27531 comm="ps" requested_mask="trace" denied_mask="trace" peer="unconfined" [29252.322147]审核:类型= 1400审核(1460734746.650:975):apparmor =“ DENIED” operation =“ ptrace” profile =“ docker-default” pid = 27531 comm =“ ps” required_mask =“ trace”遭到拒绝的mask =“ trace” peer =“ unconfined”

内chi仪表板

I have the same problem. 我也有同样的问题。 Did everything by this instruction, looks very similar like yours. 通过指令完成了所有操作,看起来与您的非常相似。 The only way I solved the problem was to start the server and client parts on different machines with different IP's. 解决问题的唯一方法是在具有不同IP的不同计算机上启动服务器和客户端部件。

After this you will have 3 connections in RabitMQ, no 'ampq' errors in sensu-client log, and successfully added client in Uchiwa. 此后,您将在RabitMQ中建立3个连接,在sensu-client日志中没有“ ampq”错误,并在Uchiwa中成功添加了客户端。

Here how it looks like. 这里看起来如何。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM