Danone89 / ZabbixMonitoringXenCenter

Python script used to monitoring XenServer for zabbix server 3.x
4 stars 3 forks source link

Error in connection between host and zabbix #2

Open AviPairupuni opened 4 years ago

AviPairupuni commented 4 years ago

Hi,

I'm trying to setup this monitoring on our POC zabbix 4.2. I'm having following error while running it manually. Can you please help. File "/usr/local/lib/python3.4/urllib/request.py", line 1182, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "/usr/local/lib/python3.4/http/client.py", line 1088, in request self._send_request(method, url, body, headers) File "/usr/local/lib/python3.4/http/client.py", line 1126, in _send_request self.endheaders(body) File "/usr/local/lib/python3.4/http/client.py", line 1084, in endheaders self._send_output(message_body) File "/usr/local/lib/python3.4/http/client.py", line 922, in _send_output self.send(msg) File "/usr/local/lib/python3.4/http/client.py", line 857, in send self.connect() File "/usr/local/lib/python3.4/http/client.py", line 1223, in connect super().connect() File "/usr/local/lib/python3.4/http/client.py", line 834, in connect self.timeout, self.source_address) File "/usr/local/lib/python3.4/socket.py", line 512, in create_connection raise err File "/usr/local/lib/python3.4/socket.py", line 503, in create_connection sock.connect(sa) TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./citrix.xenserver.py", line 499, in main(sys.argv[1:]) File "./citrix.xenserver.py", line 482, in main refreshdatefiles(xenmaster, username, password, maxage) File "./citrix.xenserver.py", line 296, in refreshdatefiles values = getStats(xenhosts, username, password, maxage) File "./citrix.xenserver.py", line 195, in getStats page = getStatsXML(hostname, username, password, delay) File "./citrix.xenserver.py", line 186, in getStatsXML pagehandle = request.urlopen(theurl) File "/usr/local/lib/python3.4/urllib/request.py", line 161, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python3.4/urllib/request.py", line 463, in open response = self._open(req, data) File "/usr/local/lib/python3.4/urllib/request.py", line 481, in _open '_open', req) File "/usr/local/lib/python3.4/urllib/request.py", line 441, in _call_chain result = func(*args) File "/usr/local/lib/python3.4/urllib/request.py", line 1225, in https_open context=self._context, check_hostname=self._check_hostname) File "/usr/local/lib/python3.4/urllib/request.py", line 1184, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>

Regards, Avinasha

Danone89 commented 4 years ago

You have timeout - check connection between zabbix host and xenserver.

Ping it and check xenserver.

czw., 2 sty 2020, 13:50 użytkownik Avinasha notifications@github.com napisał:

Hi,

I'm trying to setup this monitoring on our POC zabbix 4.2. I'm having following error while running it manually. Can you please help. File "/usr/local/lib/python3.4/urllib/request.py", line 1182, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "/usr/local/lib/python3.4/http/client.py", line 1088, in request self._send_request(method, url, body, headers) File "/usr/local/lib/python3.4/http/client.py", line 1126, in _send_request self.endheaders(body) File "/usr/local/lib/python3.4/http/client.py", line 1084, in endheaders self._send_output(message_body) File "/usr/local/lib/python3.4/http/client.py", line 922, in _send_output self.send(msg) File "/usr/local/lib/python3.4/http/client.py", line 857, in send self.connect() File "/usr/local/lib/python3.4/http/client.py", line 1223, in connect super().connect() File "/usr/local/lib/python3.4/http/client.py", line 834, in connect self.timeout, self.source_address) File "/usr/local/lib/python3.4/socket.py", line 512, in create_connection raise err File "/usr/local/lib/python3.4/socket.py", line 503, in create_connection sock.connect(sa) TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./citrix.xenserver.py", line 499, in main(sys.argv[1:]) File "./citrix.xenserver.py", line 482, in main refreshdatefiles(xenmaster, username, password, maxage) File "./citrix.xenserver.py", line 296, in refreshdatefiles values = getStats(xenhosts, username, password, maxage) File "./citrix.xenserver.py", line 195, in getStats page = getStatsXML(hostname, username, password, delay) File "./citrix.xenserver.py", line 186, in getStatsXML pagehandle = request.urlopen(theurl) File "/usr/local/lib/python3.4/urllib/request.py", line 161, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python3.4/urllib/request.py", line 463, in open response = self._open(req, data) File "/usr/local/lib/python3.4/urllib/request.py", line 481, in _open '_open', req) File "/usr/local/lib/python3.4/urllib/request.py", line 441, in _call_chain result = func(*args) File "/usr/local/lib/python3.4/urllib/request.py", line 1225, in https_open context=self._context, check_hostname=self._check_hostname) File "/usr/local/lib/python3.4/urllib/request.py", line 1184, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>

Regards, Avinasha

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Danone89/ZabbixMonitoringXenCenter/issues/2?email_source=notifications&email_token=AAFDG2ZRARGHPFCNG6ZXQATQ3XPKDA5CNFSM4KCB53K2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IDVNTCA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFDG27ZS6TVSVWDIIUJKM3Q3XPKDANCNFSM4KCB53KQ .

AviPairupuni commented 4 years ago

Thank you very much for your response.

I can ping it, nmap to the xen via 80 and 443 works just fine. but the error remains!!

I'm using a Read Only user for monitoring purpose. Is that level of permission is enough?

Here are the results of wget with https and without "s".

wget https://10.41.189.112/

--2020-01-03 09:36:46-- https://10.41.189.112/ Connecting to 10.41.189.112:443... connected. ERROR: cannot verify 10.41.189.112's certificate, issued by ‘/CN=10.41.189.112’: Self-signed certificate encountered. To connect to 10.41.189.112 insecurely, use `--no-check-certificate'.

wget http://10.41.189.112/

--2020-01-03 09:36:52-- http://10.41.189.112/ Connecting to 10.41.189.112:80... connected. HTTP request sent, awaiting response... 200 OK Length: 4214 (4.1K) [text/html] Saving to: ‘index.html.2’

100%[=============================================================================================>] 4,214 --.-K/s in 0s

2020-01-03 09:36:52 (99.6 MB/s) - ‘index.html.2’ saved [4214/4214]

[root@dserver ~]pip show XenAPI You are using pip version 6.0.8, however version 19.3.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

Name: XenAPI Version: 2.14 Location: /usr/local/lib/python3.4/site-packages Requires: six [root@dserver ~]# python -V Python 3.4.3 [root@dserver ~]#

I have updated the above path in the script and did no other changes.

AviPairupuni commented 4 years ago

@Danone89 Can you please let me know what level of access does the Citrix User needs to get this monitoring work?

Danone89 commented 4 years ago

You need to grant read all, and api access permissions (so pool operator should be fine, but I'm running it on read only). Basically if you grant lower levels you will get false alarms and/or autodiscovery won't find all vm's.

My workaround was - start as pool operator (AD will find all what it needs), then switch user to read-only.

But in your case I thinking about certificates, in my enviroment we have trusted certs on both ends ( added our CA to trusted).

AviPairupuni commented 4 years ago

Thank you for your response @Danone89 . I updated the self signed certificate from the Xen server into Zabbix server(There was already an inter-domain trust earlier). Now that the wget works fine even for https, but the script if run manually, still throwing same error.

wget https://10.41.189.112/ --2020-01-07 06:00:26-- https://10.41.189.112/ Connecting to 10.41.189.112:443... connected. HTTP request sent, awaiting response... 200 OK Length: 4214 (4.1K) [text/html] Saving to: ‘index.html’

100%[=============================================================================================>] 4,214 --.-K/s in 0s

2020-01-07 06:00:26 (30.7 MB/s) - ‘index.html’ saved [4214/4214]

AviPairupuni commented 4 years ago

Sharing some more details. Not sure what is wrong here.

Python 3.4.3 [root@dcalca1265 x0104527]# pip list Package Version


certifi 2019.11.28 chardet 3.0.4 idna 2.8 pip 19.3.1 requests 2.22.0 setuptools 44.0.0 six 1.13.0 urllib3 1.25.7 wheel 0.33.6 XenAPI 2.14

Danone89 commented 4 years ago

I Will i to this tommorow I Will have Access to my xen server

wt., 7 sty 2020, 19:25 użytkownik Avinasha notifications@github.com napisał:

Sharing some more details. Not sure what is wrong here.

Python 3.4.3 [root@dcalca1265 x0104527]# pip list Package Version

certifi 2019.11.28 chardet 3.0.4 idna 2.8 pip 19.3.1 requests 2.22.0 setuptools 44.0.0 six 1.13.0 urllib3 1.25.7 wheel 0.33.6 XenAPI 2.14

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Danone89/ZabbixMonitoringXenCenter/issues/2?email_source=notifications&email_token=AAFDG2YG2ZIMXYB2XWGYOG3Q4TCIVA5CNFSM4KCB53K2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIJZWSI#issuecomment-571710281, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFDG26KZQRDO5Y75PFIMDLQ4TCIVANCNFSM4KCB53KQ .