From 4395c7f9c479b2cd9b0df2f62810dab0d3e6e7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verch=C3=A8re?= Date: Sun, 10 Sep 2017 14:19:18 +0200 Subject: [PATCH] Refs #15. Manage disconnect --- vmware_exporter.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vmware_exporter.py b/vmware_exporter.py index dd6460b..9d07f3b 100755 --- a/vmware_exporter.py +++ b/vmware_exporter.py @@ -160,7 +160,7 @@ def collect(self, target=None, section='default'): labels=['host_name']), } - print("[{0}] Start collecting vcenter metrics for {1}".format(datetime.utcnow().replace(tzinfo=pytz.utc), target)) + print("[{0}] Start collecting vmware metrics for {1}".format(datetime.utcnow().replace(tzinfo=pytz.utc), target)) self.si = self._vmware_connect(target, section) if not self.si: @@ -192,9 +192,9 @@ def collect(self, target=None, section='default'): # Fill Hosts Informations self._vmware_get_hosts(content, metrics) - print("[{0}] Stop collecting vcenter metrics for {1}".format(datetime.utcnow().replace(tzinfo=pytz.utc), target)) + print("[{0}] Stop collecting vmware metrics for {1}".format(datetime.utcnow().replace(tzinfo=pytz.utc), target)) - self._vmware_disconnect() + self._vmware_disconnect(self.si) for metricname, metric in metrics.items(): yield metric @@ -224,7 +224,7 @@ def _vmware_get_obj(self, content, vimtype, name=None): def _vmware_connect(self, target, section): """ - Connect to Vcenter and get connection + Connect to VMWare and get connection """ context = None @@ -244,11 +244,11 @@ def _vmware_connect(self, target, section): print("Caught vmodl fault: " + error.msg) return None - def _vmware_disconnect(self): + def _vmware_disconnect(self, si): """ - Disconnect from Vcenter + Disconnect from VMWare """ - connect.Disconnect(self.si) + connect.Disconnect(si) def _vmware_perf_metrics(self, content): # create a mapping from performance stats to their counterIDs