Since Opsview Monitor 4.6.3, we have supported the monitoring of Docker hosts and containers as standard. This ability is implemented as using a Host Template named 'Application - Docker' which should be applied to all hosts which have Docker installed (and an Opsview Monitor agent).
Before applying the 'Application - Docker' host template to your Docker hosts, follow the initial instructions below:
Note: To enable the Docker API on SystemD, we had to modify the file, /lib/systemd/system/docker.service. Change the execute line to:
ExecStart=/usr/bin/docker -d -H 127.0.0.1:4243 -H unix:///var/run/docker.sock
This starts the daemon listening on port 4243 (Note that we are only listening on the loopback adapter, 127.0.0.1, as the API is not secure in this state).
Note: Docker 1.5+ update: After upgrading to the latest version (1.5.0) these settings were overwritten. After re-enabling them we had to run the command 'systemctl daemon-reload' to make them take effect.
For other Linux distributions you will need to modify the file, /etc/default/docker. Modify the DOCKER_OPTS line to:
DOCKER_OPTS="--dns 18.104.22.168 -H 127.0.0.1:4243 -H unix:///var/run/docker.sock"
Then, restart the docker service using "service docker restart" (or "/etc/init.d/docker restart" as necessary). These steps enable the plugin to connect and monitor Docker. We recommend only exposing docker on 127.0.0.1 for security purposes.
On the Docker host to be monitored:
- Install the perl LWP library - on Debian/Ubuntu use 'apt-get install libwww-perl', on CentOS/RHEL use 'yum install perl-libwww-perl'
- Install the Opsview Agent - see article
- Run the script '/usr/local/nagios/libexec/check_docker -h' - if you see an error "Can't locate JSON.pm in @INC" you also need to install the perl JSON library - see the file README on http://search.cpan.org/~makamaka/JSON-2.90/ for installation instructions. This will be included in a future version of the Opsview Agent.
In the Opsview Monitor UI:
- Create a new host within "Menu => Settings => Host Settings" for your Docker host.
- Add the Host Template "OS - Opsview Agent"
- Add the Host Template "Application - Docker"
- For any specific containers you want monitored, on the 'Variables' tab add in 'DOCKER_CONTAINER' with a value set to the container name
- Submit Changes
- Perform a configuration reload within "Menu => Settings => Reload"