diff --git a/pialert/__main__.py b/pialert/__main__.py index c337be78..d5041237 100755 --- a/pialert/__main__.py +++ b/pialert/__main__.py @@ -125,7 +125,7 @@ def main (): conf.plugins_once_run = True # check if there is a front end initiated event which needs to be executed - check_and_run_event(db) + pluginsState = check_and_run_event(db, pluginsState) # Update API endpoints update_api(db) diff --git a/pialert/initialise.py b/pialert/initialise.py index 7820faf4..d375bf13 100755 --- a/pialert/initialise.py +++ b/pialert/initialise.py @@ -85,7 +85,7 @@ def importConfigs (db): # General conf.LOG_LEVEL = ccd('LOG_LEVEL', 'verbose' , c_d, 'Log verboseness', 'text.select', "['none', 'minimal', 'verbose', 'debug']", 'General') conf.TIMEZONE = ccd('TIMEZONE', 'Europe/Berlin' , c_d, 'Time zone', 'text', '', 'General') - conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 1000 , c_d, 'Keep history entries', 'integer', '', 'General') + conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 250 , c_d, 'Keep history entries', 'integer', '', 'General') conf.PIALERT_WEB_PROTECTION = ccd('PIALERT_WEB_PROTECTION', False , c_d, 'Enable logon', 'boolean', '', 'General') conf.PIALERT_WEB_PASSWORD = ccd('PIALERT_WEB_PASSWORD', '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92' , c_d, 'Logon password', 'readonly', '', 'General') conf.INCLUDED_SECTIONS = ccd('INCLUDED_SECTIONS', ['internet', 'new_devices', 'down_devices', 'events', 'ports'] , c_d, 'Notify on', 'text.multiselect', "['internet', 'new_devices', 'down_devices', 'events', 'ports', 'plugins']", 'General') diff --git a/pialert/plugin.py b/pialert/plugin.py index f1f82ac7..a78dbee8 100755 --- a/pialert/plugin.py +++ b/pialert/plugin.py @@ -533,7 +533,7 @@ def process_plugin_events(db, plugin, pluginsState, plugEventsArr): except Exception as e: # Rollback the transaction in case of an error conn.rollback() - mylog('none', ['[Plugins] SQL transaction error: ', e]) + mylog('none', ['[Plugins] Error: ', e]) raise e # Perform database table mapping if enabled for the plugin diff --git a/pialert/plugin_utils.py b/pialert/plugin_utils.py old mode 100644 new mode 100755 diff --git a/pialert/reporting.py b/pialert/reporting.py index c7b60b4f..c4848235 100755 --- a/pialert/reporting.py +++ b/pialert/reporting.py @@ -98,9 +98,11 @@ def construct_notifications(db, sqlQuery, tableTitle, skipText = False, supplied for header in headers: html = format_table(html, header, thProps) - return noti_struc(jsn, text, html) + notiStruc = noti_struc(jsn, text, html) + mylog('debug', ['[Notification] Ports: notiStruc:', json.dumps(notiStruc.__dict__, indent=4) ]) + return notiStruc def send_notifications (db): @@ -241,7 +243,7 @@ def send_notifications (db): json_ports = conf.changedPorts_json_struc.json["data"] notiStruc = construct_notifications(db, "", "Ports", True, conf.changedPorts_json_struc) - mylog('verbose', ['[Notification] Ports: notiStruc:', notiStruc ]) + mail_html = mail_html.replace ('', notiStruc.html) portsTxt = "" @@ -483,7 +485,7 @@ def skip_repeated_notifications (db): #=============================================================================== #------------------------------------------------------------------------------- -def check_and_run_event(db): +def check_and_run_event(db, pluginsState): sql = db.sql # TO-DO sql.execute(""" select * from Parameters where par_ID = "Front_Event" """) rows = sql.fetchall() @@ -501,7 +503,7 @@ def check_and_run_event(db): if event == 'test': handle_test(param) if event == 'run': - handle_run(param, db) + pluginsState = handle_run(param, db, pluginsState) # clear event execution flag sql.execute ("UPDATE Parameters SET par_Value='finished' WHERE par_ID='Front_Event'") @@ -509,17 +511,20 @@ def check_and_run_event(db): # commit to DB db.commitDB() + return pluginsState + #------------------------------------------------------------------------------- -def handle_run(runType, db): +def handle_run(runType, db, pluginsState): mylog('minimal', ['[', timeNowTZ(), '] START Run: ', runType]) # run the plugin to run for plugin in conf.plugins: if plugin["unique_prefix"] == runType: - execute_plugin(db, plugin) + pluginsState = execute_plugin(db, plugin, pluginsState) mylog('minimal', ['[', timeNowTZ(), '] END Run: ', runType]) + return pluginsState