mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Add "cleanup" parameter
- a section for future automated cleanup tasks. - add cleanup to the .cron file - add cleaning "Online_History" exept the last 1 day
This commit is contained in:
@@ -71,13 +71,15 @@ def main ():
|
|||||||
|
|
||||||
# Check parameters
|
# Check parameters
|
||||||
if len(sys.argv) != 2 :
|
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
|
return
|
||||||
cycle = str(sys.argv[1])
|
cycle = str(sys.argv[1])
|
||||||
|
|
||||||
## Main Commands
|
## Main Commands
|
||||||
if cycle == 'internet_IP':
|
if cycle == 'internet_IP':
|
||||||
res = check_internet_IP()
|
res = check_internet_IP()
|
||||||
|
elif cycle == 'cleanup':
|
||||||
|
res = cleanup_database()
|
||||||
elif cycle == 'update_vendors':
|
elif cycle == 'update_vendors':
|
||||||
res = update_devices_MAC_vendors()
|
res = update_devices_MAC_vendors()
|
||||||
elif cycle == 'update_vendors_silent':
|
elif cycle == 'update_vendors_silent':
|
||||||
@@ -253,6 +255,26 @@ def check_IP_format (pIP):
|
|||||||
return IP.group(0)
|
return IP.group(0)
|
||||||
|
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# INTERNET IP CHANGE
|
||||||
|
#===============================================================================
|
||||||
|
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')""")
|
||||||
|
|
||||||
|
closeDB()
|
||||||
|
|
||||||
|
# OK
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# UPDATE DEVICE MAC VENDORS
|
# UPDATE DEVICE MAC VENDORS
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
@@ -11,3 +11,4 @@
|
|||||||
*/3 * * * * python ~/pialert/back/pialert.py internet_IP >~/pialert/log/pialert.IP.log 2>&1
|
*/3 * * * * python ~/pialert/back/pialert.py internet_IP >~/pialert/log/pialert.IP.log 2>&1
|
||||||
*/5 * * * * python ~/pialert/back/pialert.py 1 >~/pialert/log/pialert.1.log 2>&1
|
*/5 * * * * python ~/pialert/back/pialert.py 1 >~/pialert/log/pialert.1.log 2>&1
|
||||||
#*/15 * * * * python ~/pialert/back/pialert.py 15 >~/pialert/log/pialert.15.log 2>&1
|
#*/15 * * * * python ~/pialert/back/pialert.py 15 >~/pialert/log/pialert.15.log 2>&1
|
||||||
|
0 3 * * 1 python ~/pialert/back/pialert.py cleanup >~/pialert/log/pialert.1.log 2>&1
|
||||||
Reference in New Issue
Block a user