diff --git a/etc/linspector.conf b/etc/linspector.conf index e07ec71..0f5cc7d 100644 --- a/etc/linspector.conf +++ b/etc/linspector.conf @@ -35,6 +35,9 @@ start_scheduler = true ; 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 +; 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 max_threads = 2048 ; i recommend to set this to your number of CPU cores available when running on a dedicated Linspector host. but if the ; system is running other services you should lower this value when you have too high CPU load. if you have enough diff --git a/etc/monitors/test/test10.conf b/etc/monitors/test/test10.conf index df5e30c..030160e 100644 --- a/etc/monitors/test/test10.conf +++ b/etc/monitors/test/test10.conf @@ -4,4 +4,3 @@ service = misc.dummy hosts = 192.168.10.10 [args] -interval = 120 diff --git a/linspector/core/monitor.py b/linspector/core/monitor.py index 7773984..39030ff 100644 --- a/linspector/core/monitor.py +++ b/linspector/core/monitor.py @@ -20,13 +20,23 @@ class Monitor: self.__configuration = configuration self.__environment = environment self.__identifier = identifier - if int(monitor_configuration.get('args', 'interval')): + try: self.__interval = int(monitor_configuration.get('args', 'interval')) - else: - # default interval is 5 minutes if not set in the monitor. - log('warning', 'no interval set in identifier ' + identifier + ' set to default ' - 'interval 300 seconds.') - self.__interval = 300 + except Exception as err: + log('warning', 'no interval set in identifier ' + identifier + ', trying to get a ' + 'monitor configuration ' + 'setting. error: ' + + str(err)) + try: + self.__interval = int(configuration.get_option('linspector', 'default_interval')) + log('warning', 'set default_interval as per configuration to core with ' + 'identifier ' + identifier + ' to: ' + str(self.__interval)) + except Exception as err: + log('warning', 'no default_interval found in core configuration for identifier ' + + identifier + ', set to default interval 300 seconds. error: ' + str(err)) + # default interval is 300 seconds (5 minutes) if not set in the monitor + # configuration args or a default_interval in the core configuration. + self.__interval = 300 self.__log = log self.__monitor_configuration = monitor_configuration self.__notification_list = []