Page 1 of 2
Error when using check_docker.py
Posted: Wed May 29, 2019 3:28 pm
by dclsystems
I am getting error while using
https://nagiosxi.distributel.net/nagios ... _docker.py file:
root@docker:/usr/local/ncpa/plugins# python /usr/local/ncpa/plugins/check_docker.py -H
http://127.0.0.1:2375 -s /var/run/docker.sock --check-type 'containers_healthy' --all -t 0 --ignore-no-healthcheck -l -w '50:' -c '30:'
Traceback (most recent call last):
File "/usr/local/ncpa/plugins/check_docker.py", line 988, in <module>
_ = main()
File "/usr/local/ncpa/plugins/check_docker.py", line 959, in main
checks = choose_checks(options)
File "/usr/local/ncpa/plugins/check_docker.py", line 226, in choose_checks
check_data = get_threshold_maps(options.warning, options.critical, selection)
File "/usr/local/ncpa/plugins/check_docker.py", line 329, in get_threshold_maps
for triplet in zip(attrs.keys(), warning_list, critical_list):
AttributeError: 'list' object has no attribute 'keys'
RD
Re: Error when using check_docker.py
Posted: Wed May 29, 2019 4:38 pm
by npolovenko
Hello,
@dclsystems. First, let's make sure that you have installed all the required python modules. Please run the following commands in order, from the command line and let me know if at least one of them errors out.
Code: Select all
su nagios -c 'python -c "import sys"'
su nagios -c 'python -c "import optparse"'
su nagios -c 'python -c "from os.path import expanduser"'
su nagios -c 'python -c "import subprocess"'
su nagios -c 'python -c "import urllib"'
su nagios -c 'python -c "import json"'
su nagios -c 'python -c "import shlex"'
su nagios -c 'python -c "import signal"'
su nagios -c 'from copy import copy"'
Re: Error when using check_docker.py
Posted: Thu May 30, 2019 9:53 am
by emarmonti
Hello,
I am receiving the same error. I ran the commands you suggested. They error out with:
Code: Select all
[root@ma1p-nagiosxi ~]# su nagios -c 'from copy import copy"'
bash: -c: line 0: unexpected EOF while looking for matching `"'
bash: -c: line 1: syntax error: unexpected end of file
[root@ma1p-nagiosxi ~]#
I'm not sure exactly what this command is supposed to do, but the " is throwing it off, and also there is no "from" command installed so I'm thinking maybe that is supposed to be something completely different and you just had a typo or two?
I still receive this error:
File "/usr/local/ncpa/plugins/check_docker.py", line 988, in <module>
_ = main()
File "/usr/local/ncpa/plugins/check_docker.py", line 959, in main
checks = choose_checks(options)
File "/usr/local/ncpa/plugins/check_docker.py", line 226, in choose_checks
check_data = get_threshold_maps(options.warning, options.critical, selection)
File "/usr/local/ncpa/plugins/check_docker.py", line 329, in get_threshold_maps
for triplet in zip(attrs.keys(), warning_list, critical_list):
AttributeError: 'list' object has no attribute 'keys'
This is after following instructions at
https://assets.nagios.com/downloads/nag ... ios-XI.pdf and successfully going through the wizard to modify a docker host (via ncpa).
npolovenko wrote:Hello,
@dclsystems. First, let's make sure that you have installed all the required python modules. Please run the following commands in order, from the command line and let me know if at least one of them errors out.
Code: Select all
su nagios -c 'python -c "import sys"'
su nagios -c 'python -c "import optparse"'
su nagios -c 'python -c "from os.path import expanduser"'
su nagios -c 'python -c "import subprocess"'
su nagios -c 'python -c "import urllib"'
su nagios -c 'python -c "import json"'
su nagios -c 'python -c "import shlex"'
su nagios -c 'python -c "import signal"'
su nagios -c 'from copy import copy"'
Re: Error when using check_docker.py
Posted: Thu May 30, 2019 10:30 am
by npolovenko
@emarmonti, Sorry, I didn't spell the last command right. Please try:
Code: Select all
su nagios -c 'python -c "from copy import copy"'
Re: Error when using check_docker.py
Posted: Fri May 31, 2019 8:10 am
by emarmonti
Unfortunately running that command manually and then forcing a check on my "Docker - Container *" checks yields the same error. I can see that check_docker.py already is importing all of these modules.
Here is the error:
Code: Select all
File "/usr/local/ncpa/plugins/check_docker.py", line 988, in <module>
_ = main()
File "/usr/local/ncpa/plugins/check_docker.py", line 959, in main
checks = choose_checks(options)
File "/usr/local/ncpa/plugins/check_docker.py", line 226, in choose_checks
check_data = get_threshold_maps(options.warning, options.critical, selection)
File "/usr/local/ncpa/plugins/check_docker.py", line 329, in get_threshold_maps
for triplet in zip(attrs.keys(), warning_list, critical_list):
AttributeError: 'list' object has no attribute 'keys'
Re: Error when using check_docker.py
Posted: Fri May 31, 2019 8:37 am
by mcapra
Can you share the output of:
Code: Select all
sudo docker version
python --version
I can't actually get this plugin to work against:
Code: Select all
Server: Docker Engine - Community
Engine:
Version: 18.09.2
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 6247962
Built: Sun Feb 10 03:47:25 2019
OS/Arch: linux/amd64
Experimental: false
Code: Select all
# python check_docker.py -H http:/v1.39/ -s /var/run/docker.sock --check-type 'containers_cpu'
Traceback (most recent call last):
File "check_docker.py", line 988, in <module>
_ = main()
File "check_docker.py", line 959, in main
checks = choose_checks(options)
File "check_docker.py", line 226, in choose_checks
check_data = get_threshold_maps(options.warning, options.critical, selection)
File "check_docker.py", line 329, in get_threshold_maps
for triplet in zip(attrs.keys(), warning_list, critical_list):
AttributeError: 'list' object has no attribute 'keys'
Despite the socket responding to cURL:
Code: Select all
# curl --unix-socket /var/run/docker.sock http:/v1.39/containers/json
## Valid JSON shows up
Re: Error when using check_docker.py
Posted: Fri May 31, 2019 1:55 pm
by npolovenko
Thanks,
@mcapra.
@emarmonti, Please provide us with the versions.
Re: Error when using check_docker.py
Posted: Wed Jun 05, 2019 2:23 pm
by emarmonti
Hello!
Docker wasn't actually installed on the Nagios XI Server. Given the fact that the Docker wizard was already installed, I kind of assumed all dependencies would exist to use it.
I went ahead and installed docker-ce. The check is still failing. Here are the version numbers you were asking for.
Code: Select all
[emarmonti@ma1p-nagiosxi ~]$ docker --version
Docker version 18.09.6, build 481bc77156
[emarmonti@ma1p-nagiosxi ~]$ python --version
Python 2.7.5
[emarmonti@ma1p-nagiosxi ~]$
Re: Error when using check_docker.py
Posted: Wed Jun 05, 2019 3:56 pm
by npolovenko
@emarmonti, We found a bug in the plugin and submitted a task for the dev team. Please check back in this thread some time next week for an update. Once the bug fix has been released, we'll provide you with the new version.
Re: Error when using check_docker.py
Posted: Thu Jun 06, 2019 2:42 pm
by npolovenko
@emarmonti, UPDATE: Please move the existing check_docker plugin to a backup directory and use the modified plugin I attached to this message:
Code: Select all
mv /usr/local/nagios/libexec/check_docker.py /tmp/
Don't forget to give permissions to the new plugin before executing it:
Code: Select all
chmod 777 /usr/local/nagios/libexec/check_docker.py