timdaman / check_docker

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

support for python2 #59

Closed thatsk closed 5 years ago

thatsk commented 5 years ago

Looks like this plugin is only compatible with python3 but most of systems are on python2 so can we convert into python2

timdaman commented 5 years ago

Python 2 is end of life come January 1st. https://pythonclock.org/?1 I don't think it makes a lot of sense to spend a bunch of time validating it on legacy Python.

If you still desire using this on system that doesn't have Python 3 you can run it inside a Docker container as part of your monitoring. Here is an example

$ cat Dockerfile
FROM python:3
RUN pip install check_docker
ENTRYPOINT [ "check_docker" ]

$ docker build .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM python:3
 ---> 2cc378c061f7
Step 2/3 : RUN pip install check_docker
 ---> Using cache
 ---> 9ca5d6764412
Step 3/3 : ENTRYPOINT [ "check_docker" ]
 ---> Using cache
 ---> 114dfec0ca75
Successfully built 114dfec0ca75

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock check_docker --cpu 10:20
CRITICAL: wonderful_einstein is not "running", cannot check cpu"; CRITICAL: frosty_sanderson is not "running", cannot check cpu"; CRITICAL: quirky_ride is not "running", cannot check cpu"; OK: registry cpu is 0%; OK: wonderful_lederberg cpu is 0%; OK: nostalgic_beaver cpu is 0%|registry_cpu=0;10;20;0;100 wonderful_lederberg_cpu=0;10;20;0;100 nostalgic_beaver_cpu=0;10;20;0;100
$