diff --git a/bin/linspector b/bin/linspector index aa39085..eedb7bd 100755 --- a/bin/linspector +++ b/bin/linspector @@ -37,7 +37,7 @@ logger = logging.getLogger('linspector') # i currently only increase the 3rd number because the goal is that 0.19.* will become the first # stable version. -__version__ = '0.19.36.dev1' +__version__ = '0.19.37.dev1' __author__ = 'Johannes Findeisen ' diff --git a/etc/linspector.conf b/etc/linspector.conf index 400d846..95ffc2f 100644 --- a/etc/linspector.conf +++ b/etc/linspector.conf @@ -33,8 +33,9 @@ start_scheduler = true ; multiple processes, thread mode will run only one process with multiple threads. maybe this can be combined to run ; multiple processes with multiple threads... dont know this actually but reading the APScheduler documentation will ; explain this.... :) default is "thread" but Linspector will only run on one CPU core then. default threads are 1024 -; but this can be set much higher here. this should be minimal set to the number of monitors you are running. -scheduler_mode = process +; but this can be set much higher here. this should be minimal set to the number of monitors you are running. in process +; mode log rotating is not working as expected so i need to investigate some time to figure out what happens. +scheduler_mode = thread ; the default job interval can be set here. in the code 300 seconds are set when this option does not exist here nor in ; the monitor configuration. default_interval = 5 diff --git a/linspector/core/monitor.py b/linspector/core/monitor.py index 60f59f8..d362f0c 100644 --- a/linspector/core/monitor.py +++ b/linspector/core/monitor.py @@ -69,8 +69,8 @@ class Monitor: self.job_threshold = 0 self.enabled = True self.scheduler_job = None - # the job_id is a sha256 string. - self.job_id = self.generate_job_id() + # the monitor_id is a sha256 string. + self.monitor_id = self.generate_monitor_id() """ NONE job was not executed @@ -83,9 +83,9 @@ class Monitor: """ self.status = "NONE" self.last_execution = None - #self.monitor_information = MonitorInformation(self.job_id, self.hostgroup, self.host, + #self.monitor_information = MonitorInformation(self.monitor_id, self.hostgroup, self.host, # self.service) - self.monitor_information = MonitorInformation(self.job_id, self.service) + self.monitor_information = MonitorInformation(self.monitor_id, self.service) try: if configuration.get_option('linspector', 'notifications') or \ @@ -184,7 +184,7 @@ class Monitor: ret = "0" + ret return ret - def generate_job_id(self): + def generate_monitor_id(self): return hashlib.sha256(bytes(self.__identifier + self.host + self.hostgroups + self.service, 'utf-8')).hexdigest() @@ -198,10 +198,10 @@ class Monitor: if execution_successful: if self.job_threshold > 0: if "threshold_reset" in self.core and self.core["threshold_reset"]: - #logger.info("Job " + self.get_job_id() + ", Threshold Reset") + #logger.info("Job " + self.get_monitor_id() + ", Threshold Reset") self.job_threshold = 0 else: - #logger.info("Job " + self.get_job_id() + ", Threshold Decrement") + #logger.info("Job " + self.get_monitor_id() + ", Threshold Decrement") self.job_threshold -= 1 self.status = "OK" @@ -214,7 +214,7 @@ class Monitor: self.job_threshold += 1 if self.job_threshold >= service_threshold: - #logger.info("Job " + self.get_job_id() + ", Threshold reached!") + #logger.info("Job " + self.get_monitor_id() + ", Threshold reached!") self.status = "ERROR" self.monitor_information.set_status(self.status) @@ -244,7 +244,7 @@ class Monitor: #self.handle_threshold(self.service.get_threshold(), # self.last_execution.was_successful()) - #log.info("Job " + self.get_job_id() + + #log.info("Job " + self.get_monitor_id() + # ", Code: " + str(self.last_execution.get_error_code()) + # ", Message: " + str(self.last_execution.get_message())) @@ -253,7 +253,7 @@ class Monitor: #self.handle_tasks(self.monitor_information) else: - self.__log('info', "job " + self.get_job_id() + " disabled") + self.__log('info', "job " + self.get_monitor_id() + " disabled") def get_host(self): return self.host @@ -295,8 +295,9 @@ class MonitorExecution: self.kwargs = kwargs def get_response_message(self, job): - msg = str(job.status) + " [" + job.service.get_config_name() + ": " + str(job.get_job_id()) + "] " + \ - str(job.get_hostgroup()) + " " + str(job.get_host()) + msg = str(job.status) + " [" + job.service.get_config_name() + ": " + \ + str(job.get_monitor_id()) + "] " + str(job.get_hostgroup()) + " " + \ + str(job.get_host()) if self.get_message() is not None: msg += " " + str(self.get_message()) if self.get_kwargs() is not None: @@ -305,8 +306,8 @@ class MonitorExecution: class MonitorInformation: - def __init__(self, job_id, service): - self.job_id = job_id + def __init__(self, monitor_id, service): + self.monitor_id = monitor_id #self.hostgroup = hostgroup #self.host = host self.service = service @@ -336,8 +337,8 @@ class MonitorInformation: def inc_job_overall_wins(self): self.job_overall_wins += 1 - def get_job_id(self): - return self.job_id + def get_monitor_id(self): + return self.monitor_id def get_response_message(self): return self.response_massage