5

I created a customize Docker image based on ubuntu 14.04 with the Sensu-Client package inside.

Everything's went fine but now I'm wondering how can I trigger the checks to run from the hosts machine.

For example, I want to be able to check the processes that are running on the host machine and not only the ones running inside the container.

Thanks

Ilan
  • 569
  • 1
  • 8
  • 21

5 Answers5

1

It depends on what checks you want to run. A lot of system-level checks work fine if you run sensu container with --net=host and --privileged flags. --net=host not just allows you to see the same hostname and IP as host system, but also all the tcp connections and interface metric will match for container and host.

--privileged gives container full access to system metrics like hdd, memory, cpu.

Tricky thing is checking external process metrics, as docker isolates it even from privileged container, but you can share host's root filesystem as docker volume ( -v /:/host) and patch check to use chroot or use /host/proc instead of /proc.

Long story short, some checks will just work, for others you need to patch or develop your own way, but sensu in docker is one possible way.

DukeLion
  • 356
  • 3
  • 4
1

an unprivileged docker container cannot check processes outside of it's container because docker uses kernel namespaces to isolate it from all other processes running on the host. This is by design: docker security documentation

If you would like to run a super privileged docker container that has this namespace disabled you can run:

docker run -it --rm --privileged --pid=host alpine /bin/sh

Doing so removes an important security layer that docker provides and should be avoided if possible. Once in the container, try running ps auxf and you will see all processes on the host.

gbolo
  • 509
  • 4
  • 8
0

I don't think this is possible right now. If the processes in the host instance are running inside docker, you can mount the socket and get the status from the sensu container

Javier Segura
  • 658
  • 4
  • 13
0

Add a sensu-client to the host machine? You might want to split it out so you have granulation between problems in the containers VS problems with your hosts

Else - You would have to set up some way to report from the inside - Either using something low level (system calls etc) or set up something from outside to catch the the calls and report back status.

HTHs

YFP
  • 331
  • 3
  • 8
0

Most if not all sensu plugins hardcode the path to the proc files. One option is to mount the host proc files to a different path inside of the docker container and modify the sensu plugins to support this other location.

This is my base docker container that supports modifying the sensu plugins proc file location.

https://github.com/sstarcher/docker-sensu

Shane
  • 467
  • 1
  • 4
  • 12