From dfedaa5d2eff697f0326ca3bbbad0f8df50f7760 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Tue, 4 Oct 2022 02:19:18 +0200 Subject: [PATCH] Configuration and monitor configuration update. --- bin/linspector | 25 ++++++++++++++++++------- etc/linspector.conf | 8 +++++--- etc/monitors/network1/gateway.conf | 6 +++--- etc/monitors/network2/gateway.conf | 3 +-- etc/monitors/test/test1.conf | 1 + etc/monitors/test/test10.conf | 1 + etc/monitors/test/test2.conf | 1 + etc/monitors/test/test3.conf | 1 + etc/monitors/test/test4.conf | 1 + etc/monitors/test/test5.conf | 1 + etc/monitors/test/test6.conf | 1 + etc/monitors/test/test7.conf | 1 + etc/monitors/test/test8.conf | 1 + etc/monitors/test/test9.conf | 1 + 14 files changed, 37 insertions(+), 15 deletions(-) diff --git a/bin/linspector b/bin/linspector index c31f870..7cbc51f 100755 --- a/bin/linspector +++ b/bin/linspector @@ -34,7 +34,7 @@ from linspector.core.monitors import Monitors # i currently only increase the 3rd number because the goal is that 0.19 will become the first # stable version. -__version__ = '0.19.26.dev1' +__version__ = '0.19.27.dev1' __author__ = 'Johannes Findeisen ' logger = logging.getLogger('linspector') @@ -101,13 +101,24 @@ def main(): log_file_formatter = \ logging.Formatter('[%(asctime)s]:[%(levelname)s]:[%(name)s]:%(message)s') + + if configuration.get_option('linspector', 'log_file_size'): + log_file_size_mb = float(configuration.get_option('linspector', 'log_file_size')) + b = 1000000 + log_file_size_bytes = log_file_size_mb * b + else: + # default log file size is 10MB + log_file_size_bytes = 10485760 + + if configuration.get_option('linspector', 'log_file_count'): + log_file_count = configuration.get_option('linspector', 'log_file_count') + else: + # default log file count is 1. + log_file_count = 1 + log_file_handler = logging.handlers.RotatingFileHandler(log_file, - maxBytes=int( - configuration.get_option( - 'linspector', 'log_size')), - backupCount=int( - configuration.get_option( - 'linspector', 'log_count'))) + maxBytes=int(log_file_size_bytes), + backupCount=int(log_file_count)) log_file_handler.setFormatter(log_file_formatter) logger.addHandler(log_file_handler) diff --git a/etc/linspector.conf b/etc/linspector.conf index 0907a9d..3564095 100644 --- a/etc/linspector.conf +++ b/etc/linspector.conf @@ -2,11 +2,13 @@ [linspector] ; report core errors to the following users error_receivers = admin@example.com -log_file = ~/code/linspector/linspector/log/linspector.log ; available log levels are: "error", "warning", "info" and "debug". log_level= debug -log_count = 5 -log_size = 10485760 +log_file = ~/code/linspector/linspector/log/linspector.log +; number of log files to be kept. +log_file_count = 50 +; log file size in megabytes as float. +log_file_size = 1.00 pid_file = /var/run/user/1000/linspector.pid ; plugins separated by ','. no whitespaces allowed. not case sensitive. plugins = Lish,HTTPServer diff --git a/etc/monitors/network1/gateway.conf b/etc/monitors/network1/gateway.conf index 17c9b13..a1b722b 100644 --- a/etc/monitors/network1/gateway.conf +++ b/etc/monitors/network1/gateway.conf @@ -1,7 +1,8 @@ ; required options: [monitor] -; currently i get errors when the service option is not spelled correct. error handling need to fix this. same for -; notifications and tasks. +; The description must not but should be a unique description of the monitor for better identifying it in the database +; if a data storage tasks is being used. +description = Cable Provider service = net.fritzboxuplink hosts = 192.168.0.1,192.168.23.24,@group1,@testgroup1 interval = 60 @@ -27,6 +28,5 @@ tasks = redis hostgroups = group1 user = USERNAME password = PASSWORD -info = Cable Provider ; only alert when the error reaches the threshold threshold = 3 diff --git a/etc/monitors/network2/gateway.conf b/etc/monitors/network2/gateway.conf index 5663119..5461957 100644 --- a/etc/monitors/network2/gateway.conf +++ b/etc/monitors/network2/gateway.conf @@ -1,5 +1,5 @@ [monitor] -identifier = dsl +description = Cable Provider service = Net.FritzboxUplink interval = 60 hosts = 192.168.1.1 @@ -11,5 +11,4 @@ sms_receivers = +number1,+number2 tasks = mariadb,filelogger user = USERNAME password = PASSWORD -info = Cable Provider hostgroups = group1 \ No newline at end of file diff --git a/etc/monitors/test/test1.conf b/etc/monitors/test/test1.conf index 19e6006..03c8436 100644 --- a/etc/monitors/test/test1.conf +++ b/etc/monitors/test/test1.conf @@ -1,5 +1,6 @@ ; requireed options [monitor] +description = Test1 service = misc.dummy hosts = 192.168.10.10 interval = 60 diff --git a/etc/monitors/test/test10.conf b/etc/monitors/test/test10.conf index 6ef2bdd..7e40ba7 100644 --- a/etc/monitors/test/test10.conf +++ b/etc/monitors/test/test10.conf @@ -1,4 +1,5 @@ [monitor] +description = Test10 service = misc.dummy interval = 60 hosts = 192.168.10.10 diff --git a/etc/monitors/test/test2.conf b/etc/monitors/test/test2.conf index 1acaec1..698872e 100644 --- a/etc/monitors/test/test2.conf +++ b/etc/monitors/test/test2.conf @@ -1,4 +1,5 @@ [monitor] +description = Test2 service = misc.dummy interval = 10 hosts = 192.168.10.10 diff --git a/etc/monitors/test/test3.conf b/etc/monitors/test/test3.conf index c6479ca..79dfa8a 100644 --- a/etc/monitors/test/test3.conf +++ b/etc/monitors/test/test3.conf @@ -1,4 +1,5 @@ [monitor] +description = Test3 service = misc.dummy interval = 120 hosts = 192.168.10.10 diff --git a/etc/monitors/test/test4.conf b/etc/monitors/test/test4.conf index aafae4a..10d3042 100644 --- a/etc/monitors/test/test4.conf +++ b/etc/monitors/test/test4.conf @@ -1,4 +1,5 @@ [monitor] +description = Test4 service = misc.dummy interval = 50 hosts = 192.168.10.10 diff --git a/etc/monitors/test/test5.conf b/etc/monitors/test/test5.conf index 0e3ede3..32122d3 100644 --- a/etc/monitors/test/test5.conf +++ b/etc/monitors/test/test5.conf @@ -1,4 +1,5 @@ [monitor] +description = Test5 service = net.FritzboxUplink interval = 62 hosts = 192.168.10.10 diff --git a/etc/monitors/test/test6.conf b/etc/monitors/test/test6.conf index 41ab715..3c31d9a 100644 --- a/etc/monitors/test/test6.conf +++ b/etc/monitors/test/test6.conf @@ -1,4 +1,5 @@ [monitor] +description = Test6 service = misc.dummy interval = 30 hosts = 192.168.10.10 diff --git a/etc/monitors/test/test7.conf b/etc/monitors/test/test7.conf index 410d99f..7c1ae31 100644 --- a/etc/monitors/test/test7.conf +++ b/etc/monitors/test/test7.conf @@ -1,4 +1,5 @@ [monitor] +description = Test7 service = misc.dummy interval = 20 hosts = 192.168.10.10 diff --git a/etc/monitors/test/test8.conf b/etc/monitors/test/test8.conf index d48e6c7..5555ce8 100644 --- a/etc/monitors/test/test8.conf +++ b/etc/monitors/test/test8.conf @@ -1,4 +1,5 @@ [monitor] +description = Test8 service = misc.dummy interval = 15 hosts = 192.168.10.10 diff --git a/etc/monitors/test/test9.conf b/etc/monitors/test/test9.conf index 7b758db..b703f41 100644 --- a/etc/monitors/test/test9.conf +++ b/etc/monitors/test/test9.conf @@ -1,4 +1,5 @@ [monitor] +description = Test9 service = misc.dummy interval = 240 hosts = 192.168.10.10