sensu-plugins / sensu-plugins-docker

This plugin provides native Docker instrumentation for monitoring and metrics collection, including: container status, container number, and container metrics via `docker ps`.
http://sensu-plugins.io
MIT License
35 stars 57 forks source link

Fix docker api support #51

Closed d4n13lbc closed 7 years ago

d4n13lbc commented 7 years ago

Pull Request Checklist

Is this in reference to an existing issue? issue: https://github.com/sensu-plugins/sensu-plugins-docker/issues/45

General

New Plugins

Purpose

Suport docker api from version v1.18 to latest (1.29)

This fix is based on the following docker api response for [State][Running]:

https://docs.docker.com/engine/api/v1.29 section: INSPECT A CONTAINER Example response:

    "State": {
        "Error": "",
        "ExitCode": 9,
        "FinishedAt": "2015-01-06T15:47:32.080254511Z",
        "OOMKilled": false,
        "Dead": false,
        "Paused": false,
        "Pid": 0,
        "Restarting": false,
        "Running": true,
        "StartedAt": "2015-01-06T15:47:32.072697474Z",
        "Status": "running"
    },

Known Compatablity Issues

majormoses commented 7 years ago

is this backwards compatible with previous versions of docker? If not then we can attempt this do a rescue with the old logic in place to remain backwards compatible.

d4n13lbc commented 7 years ago

It looks like there are support for [State][Running] since 1.18 version (I checked the different api versions of the documentation https://docs.docker.com/engine/api/v1.18/ and others) . It looks like [State][Status] is supported since 1.21 version.

majormoses commented 7 years ago

OK lets either check the version and make the appropriate changes or try new method and rescue and then try the older version.

d4n13lbc commented 7 years ago

This fix should work for all documented versions. I don't see documentation for previous versions (<1.18) and not even [State][Status] existed before 1.21. It is possible to add to travis unit tests for these cases?

majormoses commented 7 years ago

Sorry I misunderstood you initially, Can we please document in readme or as a comment in the check that this check supports docker versions >= 1.18?

majormoses commented 7 years ago

I am not sure we can have a test with multiple docker versions I would need to look into that. This would be a docker in docker scenario...Minimally I need a CHANGELOG entry and ideally something documented somewhere the minimum version of docker we support.

majormoses commented 7 years ago

released: https://rubygems.org/gems/sensu-plugins-docker/versions/1.3.0