From a3702fed944bb0e50fb7df78062e345d5c53ea16 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sat, 14 Oct 2023 11:38:44 +1100 Subject: [PATCH] Debug output for #474 --- front/plugins/pihole_scan/README.md | 5 ++++- pialert/device.py | 30 +++++++++++++++++++++++++++++ pialert/plugin.py | 2 +- pialert/reporting.py | 4 ++-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/front/plugins/pihole_scan/README.md b/front/plugins/pihole_scan/README.md index bc8a3e1e3..9b63d9ed2 100755 --- a/front/plugins/pihole_scan/README.md +++ b/front/plugins/pihole_scan/README.md @@ -5,4 +5,7 @@ A plugin allowing for importing devices from the PiHole database. This is an imp ### Usage -- You need to specify the `PIHOLE_RUN_SCHD` setting and map the PiHole DB file to the path specified in the `PIHOLE_DB_PATH` setting. +- You need to specify the following settings: + - `PIHOLE_RUN` is used to enable the import by setting it e.g. to `schedule` or `once` (pre-set to `disabled`) + - `PIHOLE_RUN_SCHD` is to configure how often the plugin is executed if `PIHOLE_RUN` is set to `schedule` (pre-set to every 30 min) + - `PIHOLE_DB_PATH` setting must match the location of your PiHole database (pre-set to `/etc/pihole/pihole-FTL.db`) diff --git a/pialert/device.py b/pialert/device.py index 01227003a..6b8ccd741 100755 --- a/pialert/device.py +++ b/pialert/device.py @@ -63,6 +63,36 @@ def print_scan_stats(db): mylog('verbose', f'[Scan Stats] Disconnections.........: {stats[0]["disconnections"]}') mylog('verbose', f'[Scan Stats] IP Changes.............: {stats[0]["ip_changes"]}') + if str(stats[0]["new_devices"]) != '0': + mylog('debug', f' ================ DEVICES table content ================') + sql.execute('select * from Devices') + rows = sql.fetchall() + for row in rows: + row_dict = dict(row) + mylog('debug', f' {row_dict}') + + mylog('debug', f' ================ CurrentScan table content ================') + sql.execute('select * from CurrentScan') + rows = sql.fetchall() + for row in rows: + row_dict = dict(row) + mylog('debug', f' {row_dict}') + + mylog('debug', f' ================ Events table content where eve_PendingAlertEmail = 1 ================') + sql.execute('select * from Events where eve_PendingAlertEmail = 1') + rows = sql.fetchall() + for row in rows: + row_dict = dict(row) + mylog('debug', f' {row_dict}') + + mylog('debug', f' ================ Events table COUNT ================') + sql.execute('select count(*) from Events') + rows = sql.fetchall() + for row in rows: + row_dict = dict(row) + mylog('debug', f' {row_dict}') + + mylog('verbose', '[Scan Stats] Scan Method Statistics:') for row in stats: if row["cur_ScanMethod"] is not None: diff --git a/pialert/plugin.py b/pialert/plugin.py index 50ec89755..41ef56bd9 100755 --- a/pialert/plugin.py +++ b/pialert/plugin.py @@ -455,7 +455,7 @@ def process_plugin_events(db, plugin, pluginsState, plugEventsArr): if tmpObj.status != "missing-in-last-scan": tmpObj.changed = timeNowTZ().strftime('%Y-%m-%d %H:%M:%S') tmpObj.status = "missing-in-last-scan" - mylog('debug', [f'[Plugins] Missing from last scan (PrimaryID | SecondaryID): {tmpObj.primaryId} | {tmpObj.secondaryId}']) + # mylog('debug', [f'[Plugins] Missing from last scan (PrimaryID | SecondaryID): {tmpObj.primaryId} | {tmpObj.secondaryId}']) # Merge existing plugin objects with newly discovered ones and update existing ones with new values diff --git a/pialert/reporting.py b/pialert/reporting.py index 510af85ed..3f50a2e89 100755 --- a/pialert/reporting.py +++ b/pialert/reporting.py @@ -143,13 +143,13 @@ def get_notifications (db): mylog('verbose', ['[Notification] Open html Template']) + # select template type depoending if running latest version or an older one if conf.newVersionAvailable : template_file_path = '/back/report_template_new_version.html' else: template_file_path = '/back/report_template.html' - mylog('verbose', ['[Notification] Using template', template_file_path]) - + mylog('verbose', ['[Notification] Using template', template_file_path]) template_file = open(pialertPath + template_file_path, 'r') mail_html = template_file.read()