From ee5245eccbe9015633a542a802ee2d1ea5808914 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Fri, 11 Oct 2013 02:07:55 +0200 Subject: [PATCH] added threshold handling to job.py and config --- examples/linspector.json | 2 ++ linspector/core/job.py | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/linspector.json b/examples/linspector.json index 790cdcb..c6e3c07 100644 --- a/examples/linspector.json +++ b/examples/linspector.json @@ -184,10 +184,12 @@ } }, "core":{ + "_documentation": "https://github.com/linspector/linspector/wiki/Configuration-Core", "instance_name": "Master Monitoring (monitor.example.org)", "max_logfile_size": 1024000, "max_logfile_count": 4, "max_worker_threads": 8, + "threshold_handling": "reset", "members":[ "root" ], "backends": { "jsonrpc": { diff --git a/linspector/core/job.py b/linspector/core/job.py index 63f2632..d88bbd0 100644 --- a/linspector/core/job.py +++ b/linspector/core/job.py @@ -73,7 +73,15 @@ class Job: def handle_threshold(self, jobInfo, serviceThreshold, executionSucessful): if executionSucessful: if self.jobThreshold > 0: - self.jobThreshold -= 1 + #TODO: maybe set threshold_handling for each service optionally; will override core setting! + if self.core["threshold_handling"] == "reset": + # Reset counter to 0 + self.log.debug("Threshold Reset") + self.jobThreshold = 0 + else: + # Decrement the counter (default) + self.log.debug("Threshold Decrement") + self.jobThreshold -= 1 else: self.jobThreshold += 1