diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2016-11-12 14:00:18 +0200 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2016-11-12 14:00:18 +0200 |
commit | 56ec680880032bc9e8dcfb32bb163a1e783a6a59 (patch) | |
tree | 44d14f5808b1e2c73fe4070e851dc8ce247afa27 | |
parent | c2c0dcc86422d9073d8866347b912cadc84fddb9 (diff) |
more python logging fixes
-rwxr-xr-x | plugins.d/python.d.plugin | 2 | ||||
-rw-r--r-- | python.d/python_modules/base.py | 20 |
2 files changed, 17 insertions, 5 deletions
diff --git a/plugins.d/python.d.plugin b/plugins.d/python.d.plugin index 9fe4373ce8..83fdd17c8f 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 14c7ca1140..ca9479794c 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): |