Closed jwieder closed 5 years ago
Hi Josh,
Thanks for your report! I've just installed a clean CentOS7, updated all the packages with yum and installed the latest pypi versions of pillow
and pyzabbix
.
Unfortunately, I'm not able to reproduce the errors you are experiencing. Both http://
and https://
work fine for me.
The error you are getting (requests.exceptions.ConnectionError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
) seems to indicate an issue with hostname resolving, however you indicate this works fine when supplied as a commandline argument.
The only I can think of right now that might be troubling you could be hidden control chars in the .zbx.conf
file which might change the name in a way that is not visible from human eyes.
Can you verify no hidden chars are present in the conf file?
Regards,
Raymond
When specifying API configuration details within a .zbx.conf file, all zabbix-gnomes scripts result in one of the errors specified below.
When "api=" is specified with a protocol (http://zabbix.website.com) as per the documentation, this error is received:
Traceback (most recent call last): File "./zhostfinder.py", line 114, in
zapi.login(username, password)
File "/usr/lib/python2.7/site-packages/pyzabbix/init.py", line 68, in login
self.auth = self.user.login(user=user, password=password)
File "/usr/lib/python2.7/site-packages/pyzabbix/init.py", line 156, in fn
args or kwargs
File "/usr/lib/python2.7/site-packages/pyzabbix/init.py", line 101, in do_request
timeout=self.timeout
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 507, in post
return self.request('POST', url, data=data, json=json, kwargs)
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 464, in request
resp = self.send(prep, send_kwargs)
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
When "api=" is specified withOUT a protocol (zabbix.website.com), this error is received:
Traceback (most recent call last): File "./zhostfinder.py", line 114, in
zapi.login(username, password)
File "/usr/lib/python2.7/site-packages/pyzabbix/init.py", line 68, in login
self.auth = self.user.login(user=user, password=password)
File "/usr/lib/python2.7/site-packages/pyzabbix/init.py", line 156, in fn
args or kwargs
File "/usr/lib/python2.7/site-packages/pyzabbix/init.py", line 101, in do_request
timeout=self.timeout
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 507, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 450, in request
prep = self.prepare_request(req)
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 381, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/lib/python2.7/site-packages/requests/models.py", line 304, in prepare
self.prepare_url(url, params)
File "/usr/lib/python2.7/site-packages/requests/models.py", line 361, in prepare_url
"Perhaps you meant http://{0}?".format(url))
requests.exceptions.MissingSchema: Invalid URL u'zabbix.website.com/api_jsonrpc.php': No schema supplied. Perhaps you meant http://zabbix.website.com/api_jsonrpc.php?
I am able to connect successfully by either passing all authentication variables as command line arguments. I can also connect by pulling username & password from $HOME/.zbx.conf and passing the API URL as a command line argument. This would seem to suggest that there is a formatting issue with the api variable when retrieved from ini-style configuration files, rather than an environment-specific issue on my part, however I could easily be wrong and I do not have a ton of time to troubleshoot ATM ( I will update if I am able w/ additional info).
For example:
The instance I am using does not use SSL to connect, so my $HOME/.zbx.conf looks like this:
Error occurs with and without trailing / on api url and with or without the inclusion of the irrelevant-for-me no_verify flag.
Error occurs in CentOS 7 with Python 2.7.5 with th following modules installed:
ansible==2.4.0 ansible-cmdb==1.20 ansible-shell==0.0.5 ansible-toolkit==1.3.2 asn1crypto==0.22.0 backports.ssl-match-hostname==3.4.0.2 bcrypt==3.1.3 cffi==1.10.0 chardet==2.2.1 cryptography==1.9 decorator==3.4.0 enum34==1.1.6 idna==2.5 iniparse==0.4 ipaddr==2.1.11 ipaddress==1.0.18 Jinja2==2.9.6 jsonxs==0.4 Mako==1.0.7 MarkupSafe==1.0 paramiko==2.2.1 passlib==1.7.1 pyasn1==0.2.3 pycparser==2.18 pycurl==7.19.0 pygobject==3.22.0 pygpgme==0.3 pyliblzma==0.5.3 PyNaCl==1.1.2 pyparsing==1.5.6 pyxattr==0.5.1 PyYAML==3.12 pyzabbix==0.7.4 requests==2.6.0 Runner==1.1 six==1.10.0 slip==0.4.0 slip.dbus==0.4.0 urlgrabber==3.10 urllib3==1.10.2 ushlex==0.99 yum-metadata-parser==1.1.4 zabbix-api==0.4 zabbix-cli==1.7.0