Closed zaraquer closed 7 years ago
Did you downloaded the script to your Docker server as mentioned in the Get the script to the right path in the Docker server section?
There is a step that I forgot to mention in the README file, you need to accept the remote server fingerprint, that can be done by doing "ssh foo@remote-server.bar"..
Did you used the by_ssh method before? If not, you need to setup a paswordless ssh key for the nagios user to be able to communicate with the server without asking for a passowrd..
The icinga2 service and the docker service is on the same server now, just because I testing how can i monitor the containers. In this case the setup is different? And thank you for the fast reply!
You're welcome..
Yeah, that'll be a little bit different than a remote server.. As the 2 services are running from the same host, you can ignore the by_ssh thing..
In the commands.conf file, you can use this instead of the one mentioned in the README:
object CheckCommand "check_docker" {
command = [ PluginDir + "/docker_check.py"]
}
As you can notice, in that block I removed the by-ssh import, and changed the CheckCommand name, don't forget to use the name you used in this object to call it in the other steps..
Thanks, that error is disappeared, but now icinga ask me for the docker module which is installed already. No module named 'docker': Please install the docker module, you can use' ''pip install docker' to do that
root@xy:/usr/lib/nagios/plugins# pip install docker Requirement already satisfied (use --upgrade to upgrade): docker in /usr/local/lib/python2.7/dist-packages Cleaning up...
My fault, I should've mention that you should use pip3, because the script is based on Python3..
This should solve the issue:
pip3 install docker
I had a much longger issue after the pip3 install. And of couse, thanks for the very help! Yet, I dont get it what kind of permission is missing..
Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 356, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/lib/python3.4/http/client.py", line 1125, in request self._send_request(method, url, body, headers) File "/usr/lib/python3.4/http/client.py", line 1163, in _send_request self.endheaders(body) File "/usr/lib/python3.4/http/client.py", line 1121, in endheaders self._send_output(message_body) File "/usr/lib/python3.4/http/client.py", line 951, in _send_output self.send(msg) File "/usr/lib/python3.4/http/client.py", line 886, in send self.connect() File "/usr/local/lib/python3.4/dist-packages/docker/transport/unixconn.py", line 33, in connect sock.connect(self.unix_socket) PermissionError: [Errno 13] Permission denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/requests/adapters.py", line 423, in send timeout=timeout File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/util/retry.py", line 347, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/packages/six.py", line 685, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 356, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/lib/python3.4/http/client.py", line 1125, in request self._send_request(method, url, body, headers) File "/usr/lib/python3.4/http/client.py", line 1163, in _send_request self.endheaders(body) File "/usr/lib/python3.4/http/client.py", line 1121, in endheaders self._send_output(message_body) File "/usr/lib/python3.4/http/client.py", line 951, in _send_output self.send(msg) File "/usr/lib/python3.4/http/client.py", line 886, in send self.connect() File "/usr/local/lib/python3.4/dist-packages/docker/transport/unixconn.py", line 33, in connect sock.connect(self.unix_socket) requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/nagios/plugins/docker_check.py", line 114, in
That's the output of pip or the script?
Can you please execute the script from cli and share the output?
This is the output of the script in icinga.
But still, if I run it in commandline, its ok root@xy:/usr/lib/nagios/plugins# python /usr/lib/nagios/plugins/docker_check.py OK | nexus_mem_pct=40.0% nexus_cpu_pct=0.45% nexus_net_in=830 nexus_net_out=648 nexus_disk_in=411062272 nexus_disk_out=908083200 sonarqube_mem_pct=23.0% sonarqube_cpu_pct=0.32% sonarqube_net_in=18853969 sonarqube_net_out=10179385 sonarqube_disk_in=1014980608 sonarqube_disk_out=192942080
If I run the script from terminel, I get the right output, but in icinga2 I only got this: UNKNOWN - check_by_ssh: Remote command '/usr/lib/nagios/plugins/docker_check.py' returned status 255