Switched from JSON to ini files for configuration, lots of code adds, refactoring and even many design changes.

This commit is contained in:
Johannes Findeisen 2022-09-24 22:34:53 +02:00
commit 779c2f0b48
58 changed files with 1227 additions and 649 deletions

46
etc/monipy.ini Normal file
View file

@ -0,0 +1,46 @@
; all you need to know: https://docs.python.org/3/library/configparser.html ... ;)
; manifest:
; - no inline comments so every available character can be used in values
; - values can be overridden in each monitor
; - file names are not important but section names and key names.
; - comments can be inserted using ',' or '#'
[monipy]
; report core errors to the following users
error_receivers = admin@example.com
log_file = ~/code/monipy/log/uplink.log
log_level = verbose
log_count = 5
log_size = 10485760
pid_file = /var/run/user/1000/monipy.pid
; default delimiters '=' and ':' should be changed to ',' to be more native
plugins = httpserver,mariadb,speedtest
; maybe the run_mode is obsolete because this will be a daemon but maybe it is useful for one time execution?
; in uplink the available run_modes were cron, daemon and foreground
run_mode = cron
; every notification can be configured in it's own ini file in etc/notifications; there no notification name as prefix
; is needed. see email example.
[notifications]
; some values can be overridden in each defined monitor
sms_receivers = +34324234234:+324242344
sms_configuration_file = ~/code/monipy/etc/gammurc
; retry to send interval and number of retries if something failed
sms_resend = 10
sms_resend_count = 5
email_resend = 10
; every plugin can be configured in it's own ini file in etc/plugins; there no plugin name as prefix is needed. see
; httpserver example.
[plugins]
mariadb_database = monipy
mariadb_host = 10.0.0.254
mariadb_password = 3qx7HfrxGNM83lqN
mariadb_port": 3306
mariadb_user = uplink
speedtest_interval = 3600
speedtest_url = https://go.microsoft.com/fwlink/?Linkid=850641
; if types can or must be configured before use; for now no use case seen.
; every type can be configured in it's own ini file in etc/types; there no type name as prefix is not needed.
;[types]

View file

@ -1,9 +0,0 @@
{
"type": "uplink",
"interval": 60,
"notification": "sms",
"host": "192.168.0.1",
"user": "USERNAME",
"password": "PASSWORD",
"info": "Cable Provider"
}

View file

@ -0,0 +1,14 @@
[main]
; identifiers must be unique in the whole configuration so maybe it is better to create a random string for this
; dynamically.
identifier = cable
type = fritzbox
interval = 60
# default delimiters '=' and ':' should be changed to ',' to be more native
notifications = sms:email
email_receivers = admin@example.com:fallback@example.com
sms_receivers = +329084320984:+39804932409
host = 192.168.0.1
user = USERNAME
password = PASSWORD
info = Cable Provider

View file

@ -1,9 +0,0 @@
{
"type": "uplink",
"interval": 60,
"notification": "sms",
"host": "192.168.1.1",
"user": "USERNAME",
"password": "PASSWORD",
"info": "DSL Provider"
}

View file

@ -0,0 +1,12 @@
[main]
identifier = dsl
type = fritzbox
interval = 60
# default delimiters '=' and ':' should be changed to ',' to be more native
notifications = sms:email
email_receivers = admin@example.com:fallback@example.com
sms_receivers = +329084320984:+39804932409
host = 192.168.1.1
user = USERNAME
password = PASSWORD
info = Cable Provider

View file

@ -0,0 +1,7 @@
[email]
resend = 20
smtp_host = mail.example.com
smtp_port = 25
smtp_password = k4509knsd09
smtp_user = alert@hanez.org
receivers = admin@example.com

View file

@ -0,0 +1,3 @@
[httpserver]
ip = 127.0.0.1
port = 4242