manual merge of leiweibau and TeroRERO changes

This commit is contained in:
jokob-sk
2022-08-04 19:39:07 +10:00
parent 86ffe8ba36
commit c99f1a6e0d
9 changed files with 108 additions and 40 deletions

View File

@@ -71,7 +71,7 @@ def main ():
# Check parameters
if len(sys.argv) != 2 :
print ('usage pialert [scan_cycle] | internet_IP | update_vendors' )
print ('usage pialert [scan_cycle] | internet_IP | update_vendors | cleanup' )
return
cycle = str(sys.argv[1])
@@ -81,6 +81,8 @@ def main ():
## Main Commands
if cycle == 'internet_IP':
res = check_internet_IP()
elif cycle == 'cleanup':
res = cleanup_database()
elif cycle == 'update_vendors':
res = update_devices_MAC_vendors()
elif cycle == 'update_vendors_silent':
@@ -256,6 +258,28 @@ def check_IP_format (pIP):
return IP.group(0)
#===============================================================================
# Cleanup Online History chart
#===============================================================================
def cleanup_database ():
# Header
print ('Cleanup Database')
print (' Timestamp:', startTime )
openDB()
# Cleanup Online History
print ('\nCleanup Online_History...')
sql.execute ("""DELETE FROM Online_History WHERE Scan_Date <= date('now', '-1 day')""")
print ('\nOptimize Database...')
sql.execute ("VACUUM;")
closeDB()
# OK
return 0
#===============================================================================
# UPDATE DEVICE MAC VENDORS
#===============================================================================