timdaman / check_docker

Nagios plugin to check docker containers
GNU General Public License v3.0
152 stars 60 forks source link

Check Docker status with Icinga2 #55

Closed HigH-HawK closed 5 years ago

HigH-HawK commented 5 years ago

Hi,

I have two servers in the same network, one for Icinga2 and one where I run Docker containers. I now want to check the docker status from the Icinga2 server.

I added the check_docker plugin onto the server where I run my Docker containers as a nrpe plugin. When I run the command ./check_docker from the local machine it's working fine but when I run the command from the Icinga2 server, I get the message:

UNKNOWN: Cannot access docker socket file. User ID=996, socket file=/var/run/docker.sock

So I extended the query by adding --connect ip_to_docker_server:port but now I get an error message:

UNKNOWN: Exception raised during check': URLError(ConnectionRefusedError(111, 'Connection refused'),​)

I also added the Docker tcp port to the firewall, to make sure it can communicate but without success. I'm not sure what I'm doing wrong.

HigH-HawK commented 5 years ago

Due to the Cannot access docker socket file and mentioning the USER ID=996 (which is the user id of the nrpe user) it popped to my mind, that it may as well be a permission issue and added the nrpe user to the docker group but it didn't change anything.

HigH-HawK commented 5 years ago

Sorry for spamming but I found the solution to the error, which was actually obvious but I didn't think about it.

I added the user nrpe to the docker group instead of the nagios user, as soon as I added the nagios user to the docker group, the output was fine.

timdaman commented 5 years ago

No worries. You are not the first to get tripped up by that.

emgeepit commented 5 years ago

Im tripped up by that.... Getting the same error.. UNKNOWN: Cannot access docker socket file. User ID=492, socket file=/var/run/docker.sock

user 492 is 'icinga' and i have it added to the docker group, as well as the nagios user docker:x:495:otheruser,nagios,icinga

Any other ideas?