mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
PiHole work #513
This commit is contained in:
@@ -327,6 +327,8 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ):
|
||||
try:
|
||||
sql.execute ("ATTACH DATABASE '"+ fullSqlitePath +"' AS EXTERNAL_"+plugin["unique_prefix"])
|
||||
arr = db.get_sql_array (q)
|
||||
sql.execute ("DETACH DATABASE EXTERNAL_"+plugin["unique_prefix"])
|
||||
|
||||
except sqlite3.Error as e:
|
||||
mylog('none',[f'[Plugins] ⚠ ERROR: DB_PATH setting ({fullSqlitePath}) for plugin {plugin["unique_prefix"]}. Did you mount it correctly?'])
|
||||
mylog('none',[f'[Plugins] ⚠ ERROR: ATTACH DATABASE failed with SQL ERROR: ', e])
|
||||
|
||||
@@ -59,7 +59,7 @@ def get_notifications (db):
|
||||
|
||||
mylog('verbose', ['[Notification] included sections: ', conf.INCLUDED_SECTIONS ])
|
||||
|
||||
if 'new_devices' in conf.INCLUDED_SECTIONS :
|
||||
if 'new_devices' in conf.INCLUDED_SECTIONS:
|
||||
# Compose New Devices Section
|
||||
sqlQuery = """SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
|
||||
WHERE eve_PendingAlertEmail = 1
|
||||
@@ -75,8 +75,9 @@ def get_notifications (db):
|
||||
}
|
||||
json_new_devices = json_obj.json["data"]
|
||||
|
||||
if 'down_devices' in conf.INCLUDED_SECTIONS :
|
||||
# Compose Devices Down Section
|
||||
if 'down_devices' in conf.INCLUDED_SECTIONS:
|
||||
# Compose Devices Down Section
|
||||
# - select only Down Alerts with pending email of devices that didn't reconnect within the specified time window
|
||||
sqlQuery = f"""
|
||||
SELECT *
|
||||
FROM Events AS down_events
|
||||
@@ -102,7 +103,7 @@ def get_notifications (db):
|
||||
}
|
||||
json_down_devices = json_obj.json["data"]
|
||||
|
||||
if 'events' in conf.INCLUDED_SECTIONS :
|
||||
if 'events' in conf.INCLUDED_SECTIONS:
|
||||
# Compose Events Section
|
||||
sqlQuery = """SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
|
||||
WHERE eve_PendingAlertEmail = 1
|
||||
@@ -142,7 +143,7 @@ def get_notifications (db):
|
||||
"events_meta": json_events_meta,
|
||||
"plugins": json_plugins,
|
||||
"plugins_meta": json_plugins_meta,
|
||||
}
|
||||
}
|
||||
|
||||
return final_json
|
||||
|
||||
|
||||
Reference in New Issue
Block a user