prevent breaking everything in create() and check()
paulfantom committed
Jun 12, 2016 at 15:59 UTC
ce0abe5bab974d970a817e12ecafa953a0dc407a
1 file changed
+9
-5
plugins.d/python.d.plugin
+9
-5
@@ -137,8 +137,8 @@ class PythonCharts(object):
137
self.disable_module(mod, "failed check")
138
except AttributeError:
139
self.disable_module(mod, "no check")
140
- except UnboundLocalError:
141
- self.disable_module(mod, "misbehaving")
140
+ except (UnboundLocalError, Exception) as e:
141
+ self.disable_module(mod, "misbehaving. Reason: " + str(e))
142
143
def create(self):
144
for mod in self.modules:
@@ -159,8 +159,8 @@ class PythonCharts(object):
159
sys.stdout.flush()
160
except AttributeError:
161
self.disable_module(mod, "no create")
162
- except UnboundLocalError:
163
- self.disable_module(mod, "misbehaving")
162
+ except (UnboundLocalError, Exception) as e:
163
+ self.disable_module(mod, "misbehaving. Reason: " + str(e))
164
165
def update_module(self, mod):
166
t_start = time.time()
@@ -221,7 +221,11 @@ def read_config(path):
221
except IsADirectoryError:
222
debug(str(path), "is a directory")
223
return
224
- config.read_string(config_str)
224
+ try:
225
+ config.read_string(config_str)
226
+ except configparser.ParsingError as e:
227
+ debug("Malformed configuration file: "+str(e))
228
+ return
229
return dict(config.items('config'))
230
231