Cosmetic changes and some more inline comments.

This commit is contained in:
Johannes Findeisen 2022-10-01 22:02:32 +02:00
commit f4e3b9c01b
5 changed files with 15 additions and 10 deletions

View file

@ -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 <you@hanez.org>'
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)

View file

@ -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

View file

@ -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))

View file

@ -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

View file

@ -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