From f4e3b9c01b37fb1295da2b057dbacdab2a88445b Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Sat, 1 Oct 2022 22:02:32 +0200 Subject: [PATCH] Cosmetic changes and some more inline comments. --- bin/linspector | 9 ++++++--- etc/linspector.conf | 4 +++- linspector/core/helpers.py | 8 ++++---- linspector/services/misc/dummy.py | 2 +- linspector/services/net/fritzboxuplink.py | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bin/linspector b/bin/linspector index e1bde86..98bf00e 100755 --- a/bin/linspector +++ b/bin/linspector @@ -32,9 +32,9 @@ from linspector.core.environment import Environment from linspector.core.linspector import Linspector from linspector.core.monitors import Monitors -# i currently only set the 3rd number because the goal is that 0.19 will become the first stable -# version. -__version__ = '0.19.17.dev1' +# i currently only increase the 3rd number because the goal is that 0.19 will become the first +# stable version. +__version__ = '0.19.19.dev1' __author__ = 'Johannes Findeisen ' logger = logging.getLogger('linspector') @@ -72,6 +72,8 @@ def main(): monitors = None notifications = {} plugins = {} + # the scheduler is a dict to make it possible in the future to run more than one scheduler in + # one linspector daemon. need to think about it a little more... scheduler = {} services = {} tasks = {} @@ -105,6 +107,7 @@ def main(): backupCount=int( configuration.get_option( 'linspector', 'log_count'))) + log_file_handler.setFormatter(log_file_formatter) logger.addHandler(log_file_handler) diff --git a/etc/linspector.conf b/etc/linspector.conf index 88fae57..09e0001 100644 --- a/etc/linspector.conf +++ b/etc/linspector.conf @@ -31,7 +31,8 @@ max_processes = 24 timezone = CET ; this is for scheduling jobs to not run all at the same time. this should be set to the lowest interval you use. it ; can be set to a lower value if you only have a small amount of services you are monitoring. i recommend the lowest -; interval you use any any monitor. it is always starting with 0. default is 60. +; interval you use any any monitor. it is always starting with 0. default is 60. the current setting is for development +; only. delta_range = 10 ; hostgroup parents; if the hostgroup "group1" is down, don't alert for the hosts in group2. see TODO.txt for more @@ -47,6 +48,7 @@ group1 = group2 ; add single hosts group1 = host1,host2,host3 ; add a range of ip addresses. maybe a different range operator should be chosen but for now i think ">" is sexy... :) +; for ip ranges see: https://stackoverflow.com/questions/19157307/generate-range-of-ips-in-python group2 = 192.168.1.1>192.168.1.127 ; add a combination of hosts and ranges group3 = host1,host2,host3,192.168.1.1>192.168.1.127 diff --git a/linspector/core/helpers.py b/linspector/core/helpers.py index 7a3722c..758bbf0 100644 --- a/linspector/core/helpers.py +++ b/linspector/core/helpers.py @@ -12,10 +12,10 @@ def log(level, msg): # only use inspect when log level NOTSET or DEBUG is enabled. if logger.isEnabledFor(0) or logger.isEnabledFor(10): import inspect - frm = inspect.stack()[1] - function_name = frm.function - module_name = inspect.getmodule(frm[0]).__name__ - line_number = str(frm.lineno) + from_stack = inspect.stack()[1] + function_name = from_stack.function + module_name = inspect.getmodule(from_stack[0]).__name__ + line_number = str(from_stack.lineno) if level == 'critical': logger.critical('[' + module_name + ']:[' + function_name + ']:[' + line_number + '] ' + str(msg)) diff --git a/linspector/services/misc/dummy.py b/linspector/services/misc/dummy.py index 8a1821e..b7309ed 100644 --- a/linspector/services/misc/dummy.py +++ b/linspector/services/misc/dummy.py @@ -19,6 +19,6 @@ class DummyService(Service): self.__environment = environment def execute(self, **kwargs): - log('debug', 'dummy object @' + str(self)) + log('debug', 'dummy object ' + str(self)) #log('debug', 'dummy object @' + str(self) + str(self.__kwargs['foo'])) return diff --git a/linspector/services/net/fritzboxuplink.py b/linspector/services/net/fritzboxuplink.py index bb67e99..11b23f2 100644 --- a/linspector/services/net/fritzboxuplink.py +++ b/linspector/services/net/fritzboxuplink.py @@ -21,5 +21,5 @@ class FritzboxUplinkService(Service): self.__environment = environment def execute(self, **kwargs): - log('debug', 'fritzboxuplink object @' + str(self)) + log('debug', 'fritzboxuplink object ' + str(self)) return