]> arthur.barton.de Git - netdata.git/blobdiff - plugins.d/python.d.plugin
add log flood prevention
[netdata.git] / plugins.d / python.d.plugin
index 085d4fc7cfe9beb83a5c4fc6741c770957e3b448..5a8768d42321c95656dfb1a52335007d9b16a9d3 100755 (executable)
@@ -353,7 +353,7 @@ class PythonCharts(object):
                         pass
             except AttributeError as e:
                 self._stop(job)
-                msg.error(job.chart_name, "cannot find check() function.")
+                msg.error(job.chart_name, "cannot find check() function or it thrown unhandled exception.")
                 msg.debug(str(e))
             except (UnboundLocalError, Exception) as e:
                 msg.error(job.chart_name, str(e))
@@ -390,7 +390,7 @@ class PythonCharts(object):
                     # sys.stdout.flush()
                     i += 1
             except AttributeError:
-                msg.error(job.chart_name, "cannot find create() function.")
+                msg.error(job.chart_name, "cannot find create() function or it thrown unhandled exception.")
                 self._stop(job)
             except (UnboundLocalError, Exception) as e:
                 msg.error(job.chart_name, str(e))
@@ -495,6 +495,14 @@ def run():
             DEBUG_FLAG = conf['debug']
         except (KeyError, TypeError):
             pass
+        try:
+            log_counter = conf['logs_per_interval']
+        except (KeyError, TypeError):
+            log_counter = 200
+        try:
+            log_interval = conf['log_interval']
+        except (KeyError, TypeError):
+            log_interval = 3600
         for k, v in conf.items():
             if k in ("update_every", "debug", "enabled"):
                 continue
@@ -504,6 +512,8 @@ def run():
     # parse passed command line arguments
     modules = parse_cmdline(MODULES_DIR, *sys.argv)
     msg.DEBUG_FLAG = DEBUG_FLAG
+    msg.LOG_COUNTER = log_counter
+    msg.LOG_INTERVAL = log_interval
     msg.info("MODULES_DIR='" + MODULES_DIR +
              "', CONFIG_DIR='" + CONFIG_DIR +
              "', UPDATE_EVERY=" + str(BASE_CONFIG['update_every']) +