Mk_docker.py on 1.6.0p11 is not running with Python3

Hey,

python2 is dead since January 2020 officially - but mk_docker.py is not working with Python 3.
Got it running with 2to3 utility, but now I become the following error
<<<docker_node_info:sep(0)>>>
@docker_version_info{“PluginVersion”: “0.1”, “DockerPyVersion”: “4.2.0”, “ApiVersion”: “1.40”}
{“Unknown”: “Plugin exception in section_container_agent: ‘SocketIO’ object has no attribute ‘recv’”}

The other checks working fine, but for the agent status I got an unknown error
Any ideas? Downgrade to python2 is not an option.

Regards
Günther

Inside github you find already two versions of the mk_docker plugin.

That is relative - as long as you have RHEL 6 and 7 official supported out there you will also have python 2.7 out there as the default version on many enterprise systems

Thx for the hint, will try it. Regarding support: hm, but hopefully checkmk is not only for RHEL :wink: ?

Ok, checked it, I guess mk_docker.py is python3. So the error is still there:
<<<docker_node_info:sep(0)>>>
@docker_version_info{“PluginVersion”: “0.1”, “DockerPyVersion”: “4.2.0”, “ApiVersion”: “1.40”}
{“Unknown”: “Plugin exception in section_container_agent: ‘SocketIO’ object has no attribute ‘recv’”}

Günther

This error looks more like a problem that the plugin cannot read data from the docker.sock.
How does your config file looks like and where is your docker.sock inside the system.

Was this the only output the agent plugin is producing?

On my host I have this line but also all the other output.

Inside the mk_docker is also one small bug.

def section_node_images(client):
    '''in subsections list [[[images]]] and [[[containers]]]'''
    section = Section('node_images')

    images = client.images.list()
    LOGGER.debug(images)
    section.append('[[[images]]]')
    for image in images:
        section.append(json.dumps(image.attrs))

    LOGGER.debug(client.all_containers)
    section.append('[[[containers]]]')
    for container in client.all_containers.itervalues():
        section.append(json.dumps(container.attrs))

    section.write()

Change to

def section_node_images(client):
    '''in subsections list [[[images]]] and [[[containers]]]'''
    section = Section('node_images')

    images = client.images.list()
    LOGGER.debug(images)
    section.append('[[[images]]]')
    for image in images:
        section.append(json.dumps(image.attrs))

    LOGGER.debug(client.all_containers)
    section.append('[[[containers]]]')
    for container in client.all_containers:
        section.append(json.dumps(client.all_containers[container].attrs))

    section.write()

Hi,

no, just the single check node info is not
working. And I guess the configuration for
showing name, id short or long is related to this.
This is also not working, but the rest is working
fine. I habe a lot of checks, containers are created
and so on… just this single one and the naming rule.

Regards
Guenther

This exception i get only if inside the container is no CMK agent installed. With this one modification before all other things are working.
The exception is correct if you have no agent inside your containers.

You can disable the execution of the checkmk agent inside the container in the configuration of the mk_docker agent plugin.

Use the agent bakery or create /etc/check_mk/docker.cfg with:

[DOCKER]
skip_sections: docker_container_agent

Ah ok! I have no agents installed. But in this case
do you think the rule for naming is also not
working? I have a static name mapping for my
container

jepp already done it yesterday. Thx!

The different naming options are working here.
Short ID, long ID or name is ok.

Hi Andreas,

yes, if I configure it via /etc/check_mk/docker.cfg it works
but I tried it with rules - this doesn’t work - but in the documentation
they mentioned the rule based way.

It’s working at your site with cfg or with rules?

Regards
Guenther

yeah, verified it again. If I follow the documentation regarding the ruleset - this does not
work; if I set it in docker.cfg, all is working fine. I guess the ruleset is valid only in combination
with agent backery…?

Regrads
Guenther

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.