From: Costa Tsaousis (ktsaou) Date: Sat, 12 Nov 2016 12:00:18 +0000 (+0200) Subject: more python logging fixes X-Git-Tag: v1.5.0~188^2~28 X-Git-Url: https://arthur.barton.de/gitweb/?p=netdata.git;a=commitdiff_plain;h=56ec680880032bc9e8dcfb32bb163a1e783a6a59 more python logging fixes --- diff --git a/plugins.d/python.d.plugin b/plugins.d/python.d.plugin index 9fe4373c..83fdd17c 100755 --- a/plugins.d/python.d.plugin +++ b/plugins.d/python.d.plugin @@ -332,7 +332,7 @@ class PythonCharts(object): job = self.jobs[i] try: if not job.check(): - msg.error(job.chart_name, "check function failed.") + msg.error(job.chart_name, "check() failed - disabling job") self._stop(job) else: msg.info("CHECKED OK:", job.chart_name) diff --git a/python.d/python_modules/base.py b/python.d/python_modules/base.py index 14c7ca11..ca947979 100644 --- a/python.d/python_modules/base.py +++ b/python.d/python_modules/base.py @@ -357,10 +357,18 @@ class SimpleService(threading.Thread): :return: boolean """ self.debug("Module", str(self.__module__), "doesn't implement check() function. Using default.") - if self._get_data() is None or len(self._get_data()) == 0: + data = self._get_data() + + if data is None: + self.debug("failed to receive data during check().") return False - else: - return True + + if len(data) == 0: + self.debug("empty data during check().") + return False + + self.debug("successfully received data during check(): '" + str(data) + "'") + return True def create(self): """ @@ -369,6 +377,7 @@ class SimpleService(threading.Thread): """ data = self._get_data() if data is None: + self.debug("failed to receive data during create().") return False idx = 0 @@ -392,7 +401,7 @@ class SimpleService(threading.Thread): """ data = self._get_data() if data is None: - self.debug("_get_data() returned no data") + self.debug("failed to receive data during update().") return False updated = False @@ -716,6 +725,7 @@ class SocketService(SimpleService): self.name = "" else: self.name = str(self.name) + try: self.unix_socket = str(self.configuration['socket']) except (KeyError, TypeError): @@ -729,10 +739,12 @@ class SocketService(SimpleService): self.port = int(self.configuration['port']) except (KeyError, TypeError): self.debug("No port specified. Using: '" + str(self.port) + "'") + try: self.request = str(self.configuration['request']) except (KeyError, TypeError): self.debug("No request specified. Using: '" + str(self.request) + "'") + self.request = self.request.encode() def check(self):