Skip to content

Commit

Permalink
Debug output for #474
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Oct 14, 2023
1 parent 3e3e8fa commit a3702fe
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
5 changes: 4 additions & 1 deletion front/plugins/pihole_scan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
30 changes: 30 additions & 0 deletions pialert/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pialert/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pialert/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a3702fe

Please sign in to comment.