mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
This commit is contained in:
@@ -536,7 +536,7 @@ The arp-scan time itself depends on the number of IP addresses to check so set t
|
||||
'ENABLE_PLUGINS_name' => 'Enable Plugins',
|
||||
'ENABLE_PLUGINS_description' => 'Enables the <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/tree/main/pialert/plugins">plugins</a> functionality. Loading plugins requires more hardware resources so you might want to disable them on low-powered system.',
|
||||
'PLUGINS_KEEP_HIST_name' => 'Plugins History',
|
||||
'PLUGINS_KEEP_HIST_description' => 'How many days of Plugins History scan entries should be kept (globally, not device specific!).',
|
||||
'PLUGINS_KEEP_HIST_description' => 'How many entries of Plugins History scan results should be kept (globally, not device specific!).',
|
||||
'PIALERT_WEB_PROTECTION_name' => 'Enable login',
|
||||
'PIALERT_WEB_PROTECTION_description' => 'When enabled a login dialog is displayed. Read below carefully if you get locked out of your instance.',
|
||||
'PIALERT_WEB_PASSWORD_name' => 'Login password',
|
||||
|
||||
0
front/plugins/README.md
Normal file → Executable file
0
front/plugins/README.md
Normal file → Executable file
@@ -91,22 +91,30 @@ class DB():
|
||||
order by Scan_Date desc limit 150)""")
|
||||
mylog('verbose', ['[DB Cleanup] Optimize Database'])
|
||||
# Cleanup Events
|
||||
mylog('verbose', [f'[DB Cleanup] Events: Delete all older than {str(DAYS_TO_KEEP_EVENTS)} days'])
|
||||
mylog('verbose', [f'[DB Cleanup] Events: Delete all older than {str(DAYS_TO_KEEP_EVENTS)} days (DAYS_TO_KEEP_EVENTS setting)'])
|
||||
self.sql.execute (f"""DELETE FROM Events
|
||||
WHERE eve_DateTime <= date('now', '-{str(DAYS_TO_KEEP_EVENTS)} day')""")
|
||||
|
||||
# Cleanup Plugin Events History
|
||||
mylog('verbose', ['[DB Cleanup] Plugin Events History: Delete all older than '+str(DAYS_TO_KEEP_EVENTS)+' days'])
|
||||
mylog('verbose', ['[DB Cleanup] Plugin Events History: Delete all older than '+str(DAYS_TO_KEEP_EVENTS)+' days (DAYS_TO_KEEP_EVENTS setting)'])
|
||||
self.sql.execute (f"""DELETE FROM Plugins_History
|
||||
WHERE DateTimeChanged <= date('now', '{str(DAYS_TO_KEEP_EVENTS)} day')""")
|
||||
|
||||
# Trim Plugins_History entries to less than PLUGINS_KEEP_HIST setting
|
||||
mylog('verbose', [f'[DB Cleanup] Plugins_History: Trim Plugins_History entries to less than {str(PLUGINS_KEEP_HIST)} (PLUGINS_KEEP_HIST setting)'])
|
||||
self.sql.execute (f"""DELETE from Plugins_History where "Index" not in (
|
||||
SELECT "Index" from Plugins_History
|
||||
order by "Index" desc limit {str(PLUGINS_KEEP_HIST)})""")
|
||||
|
||||
# Cleanup Pholus_Scan
|
||||
if PHOLUS_DAYS_DATA != 0:
|
||||
mylog('verbose', ['[DB Cleanup] Pholus_Scan: Delete all older than ' + str(PHOLUS_DAYS_DATA) + ' days'])
|
||||
mylog('verbose', ['[DB Cleanup] Pholus_Scan: Delete all older than ' + str(PHOLUS_DAYS_DATA) + ' days (PHOLUS_DAYS_DATA setting)'])
|
||||
# todo: improvement possibility: keep at least N per mac
|
||||
self.sql.execute (f"""DELETE FROM Pholus_Scan
|
||||
WHERE Time <= date('now', '-{str(PHOLUS_DAYS_DATA)} day')""")
|
||||
# Cleanup New Devices
|
||||
if HRS_TO_KEEP_NEWDEV != 0:
|
||||
mylog('verbose', [f'[DB Cleanup] Devices: Delete all New Devices older than {str(HRS_TO_KEEP_NEWDEV)} hours'])
|
||||
mylog('verbose', [f'[DB Cleanup] Devices: Delete all New Devices older than {str(HRS_TO_KEEP_NEWDEV)} hours (HRS_TO_KEEP_NEWDEV setting)'])
|
||||
self.sql.execute (f"""DELETE FROM Devices
|
||||
WHERE dev_NewDevice = 1 AND dev_FirstConnection < date('now', '+{str(HRS_TO_KEEP_NEWDEV)} hour')""")
|
||||
|
||||
@@ -120,7 +128,7 @@ class DB():
|
||||
AND Pholus_Scan.Record_Type = p2.Record_Type
|
||||
);""")
|
||||
# De-Dupe (de-duplicate - remove duplicate entries) from the Nmap_Scan table
|
||||
mylog('verbose', [' Nmap_Scan: Delete all duplicates'])
|
||||
mylog('verbose', ['[DB Cleanup] Nmap_Scan: Delete all duplicates'])
|
||||
self.sql.execute ("""DELETE FROM Nmap_Scan
|
||||
WHERE rowid > (
|
||||
SELECT MIN(rowid) FROM Nmap_Scan p2
|
||||
@@ -130,13 +138,10 @@ class DB():
|
||||
AND Nmap_Scan.Service = p2.Service
|
||||
);""")
|
||||
|
||||
# Delete all Plugins_History entries older than PLUGINS_KEEP_HIST setting
|
||||
mylog('verbose', [f' Plugins_History: Delete all Plugins_History entries older than {str(PLUGINS_KEEP_HIST)} (PLUGINS_KEEP_HIST setting) days'])
|
||||
self.sql.execute (f"""DELETE FROM Plugins_History
|
||||
WHERE DateTimeChanged <= date('now', '-{str(PLUGINS_KEEP_HIST)} day')""")
|
||||
|
||||
|
||||
# Shrink DB
|
||||
mylog('verbose', [' Shrink Database'])
|
||||
mylog('verbose', ['[DB Cleanup] Shrink Database'])
|
||||
self.sql.execute ("VACUUM;")
|
||||
self.commitDB()
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def importConfigs (db):
|
||||
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.ENABLE_PLUGINS = ccd('ENABLE_PLUGINS', True , c_d, 'Enable plugins', 'boolean', '', 'General')
|
||||
conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 7 , c_d, 'Keep history days', 'integer', '', 'General')
|
||||
conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 10000 , 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')
|
||||
|
||||
Reference in New Issue
Block a user