From d0ad78920fbb0252d93509c4d774d04dd1b0d211 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Tue, 27 Dec 2022 14:08:57 +1100 Subject: [PATCH] logs fixes --- README.md | 2 +- back/pialert.py | 60 ++++++++++++------------ dockerfiles/README.md | 8 ++-- front/css/pialert.css | 26 ++++++++++ front/maintenance.php | 86 ++++++++++++++++++++++------------ front/php/templates/header.php | 2 +- 6 files changed, 117 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 7e5767ab..b8c5b3ac 100755 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Instructions for [pucherot's original code can be found here](https://github.com [main]: ./docs/img/devices_split.png "Main screen" -[screen1]: ./docs/img/devices_details.png "Screen 1" +[screen1]: ./docs/img/device_details.png "Screen 1" [screen2]: ./docs/img/events.png "Screen 2" [screen3]: ./docs/img/presence.png "Screen 3" [screen4]: ./docs/img/maintenance.png "Screen 4" diff --git a/back/pialert.py b/back/pialert.py index 0d3b91e6..8995406f 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -506,7 +506,7 @@ def main (): # proceed if 1 minute passed if last_run + timedelta(minutes=1) < time_now : - # last time any scan or maintennace was run + # last time any scan or maintennace/Upkeep was run last_run = time_now reporting = False @@ -552,7 +552,7 @@ def main (): # Final message if cycle != "": action = str(cycle) - if cycle == "1": + if action == "1": action = "network_scan" file_print('[', time_now.replace (microsecond=0), '] Last action: ', action) cycle = "" @@ -575,7 +575,7 @@ def check_internet_IP (): reporting = False # Header - updateState("Scanning: Internet IP") + updateState("Scan: Internet IP") file_print('[', startTime, '] Check Internet IP:') # Get Internet IP @@ -744,18 +744,18 @@ def check_IP_format (pIP): #=============================================================================== def cleanup_database (): # Header - updateState("Maintenance: DB cleanup") - file_print('[', startTime, '] Cleanup Database:' ) + updateState("Upkeep: Clean DB") + file_print('[', startTime, '] Upkeep Database:' ) openDB() # Cleanup Online History - file_print(' Cleanup Online_History') + file_print(' Upkeep Online_History') sql.execute ("DELETE FROM Online_History WHERE Scan_Date <= date('now', '-1 day')") file_print(' Optimize Database') # Cleanup Events - file_print(' Cleanup Events, up to the lastest '+str(DAYS_TO_KEEP_EVENTS)+' days') + file_print(' Upkeep Events, up to the lastest '+str(DAYS_TO_KEEP_EVENTS)+' days') sql.execute ("DELETE FROM Events WHERE eve_DateTime <= date('now', '-"+str(DAYS_TO_KEEP_EVENTS)+" day')") # Shrink DB @@ -769,11 +769,11 @@ def cleanup_database (): #=============================================================================== def update_devices_MAC_vendors (pArg = ''): # Header - updateState("Maintenance: Update HW Vendors") - file_print('[', startTime, '] Update HW Vendors:' ) + updateState("Upkeep: Vendors") + file_print('[', startTime, '] Upkeep - Update HW Vendors:' ) # Update vendors DB (iab oui) - file_print('\nUpdating vendors DB (iab & oui)') + file_print(' Updating vendors DB (iab & oui)') # update_args = ['sh', PIALERT_BACK_PATH + '/update_vendors.sh', ' > ', logPath + '/update_vendors.log', '2>&1'] update_args = ['sh', PIALERT_BACK_PATH + '/update_vendors.sh', pArg] @@ -794,7 +794,7 @@ def update_devices_MAC_vendors (pArg = ''): notFound = 0 # All devices loop - file_print('\nSearching devices vendor') + file_print(' Searching devices vendor') openDB() for device in sql.execute ("SELECT * FROM Devices") : # Search vendor in HW Vendors DB @@ -889,7 +889,7 @@ def scan_network (): # # devtest end # Header - updateState("Scanning: Network") + updateState("Scan: Network") file_print('[', startTime, '] Scan Devices:' ) file_print(' ScanCycle:', cycle) @@ -1942,45 +1942,45 @@ def email_reporting (): # Send Mail if json_internet != [] or json_new_devices != [] or json_down_devices != [] or json_events != []: - file_print('Changes detected, sending reports') + file_print(' Changes detected, sending reports') if REPORT_MAIL and check_config('email'): - updateState("Sending: Email") - file_print(' Sending report by Email') + updateState("Send: Email") + file_print(' Sending report by Email') send_email (mail_text, mail_html) else : file_print(' Skip mail') if REPORT_APPRISE and check_config('apprise'): - updateState("Sending: Apprise") - file_print(' Sending report by Apprise') + updateState("Send: Apprise") + file_print(' Sending report by Apprise') send_apprise (mail_html) else : - file_print(' Skip Apprise') + file_print(' Skip Apprise') if REPORT_WEBHOOK and check_config('webhook'): - updateState("Sending: Webhook") - file_print(' Sending report by Webhook') + updateState("Send: Webhook") + file_print(' Sending report by Webhook') send_webhook (json_final, mail_text) else : - file_print(' Skip webhook') + file_print(' Skip webhook') if REPORT_NTFY and check_config('ntfy'): - updateState("Sending: NTFY") - file_print(' Sending report by NTFY') + updateState("Send: NTFY") + file_print(' Sending report by NTFY') send_ntfy (mail_text) else : - file_print(' Skip NTFY') + file_print(' Skip NTFY') if REPORT_PUSHSAFER and check_config('pushsafer'): - updateState("Sending: PUSHSAFER") - file_print(' Sending report by PUSHSAFER') + updateState("Send: PUSHSAFER") + file_print(' Sending report by PUSHSAFER') send_pushsafer (mail_text) else : - file_print(' Skip PUSHSAFER') + file_print(' Skip PUSHSAFER') # Update MQTT entities if REPORT_MQTT and check_config('mqtt'): - updateState("Sending: MQTT") - file_print(' Establishing MQTT thread') + updateState("Send: MQTT") + file_print(' Establishing MQTT thread') mqtt_start() else : - file_print(' Skip MQTT') + file_print(' Skip MQTT') else : file_print(' No changes to report') diff --git a/dockerfiles/README.md b/dockerfiles/README.md index f5c46787..90ff2ea4 100755 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -8,11 +8,11 @@ 🐳 [Docker hub](https://registry.hub.docker.com/r/jokobsk/pi.alert) | 📄 [Dockerfile](https://github.com/jokob-sk/Pi.Alert/blob/main/Dockerfile) | 📚 [Docker instructions](https://github.com/jokob-sk/Pi.Alert/blob/main//dockerfiles/README.md) - - + + - - + + diff --git a/front/css/pialert.css b/front/css/pialert.css index af548be4..cf0b8fb9 100755 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -27,10 +27,36 @@ font-family: 'Courier New', monospace; } +.logs-row +{ + align-content: center; + width: 100%; + display: grid; + margin: 5px; +} +.log-area +{ + padding: 3px; + width:100%; + border-bottom-width: 1px; + border-bottom-style: solid; + border-color: #606060; +} .logs-small { height: 100px; } +.log-file +{ + width: 145px; + display: inline-grid; + font-size: 20px; +} +.log-purge +{ + width: 90px; + float:right; +} .span-padding { padding:10px; diff --git a/front/maintenance.php b/front/maintenance.php index a8fbc4e5..c21d3b73 100755 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -346,55 +346,79 @@ if (submit && isset($_POST['skinselector_set'])) {
-
-
-
-
-
-
+
+
-
-
-
-
-
+
+
+
pialert.log
+
+ +
+
-
+
+
+
-
-
-
-
-
+
+
+
pialert_front.log
+
+ +
+
-
+
+
+ +
-
+
+
+
+
IP_changes.log
+
+ +
+
+
+
-
-
-
-
-
-
+
+
+
+
+
stdout.log
+
+ +
+
+
+
-
-
-
-
-
-
+
+
+
+
+
stderr.log
+
+ +
+
+
+
diff --git a/front/php/templates/header.php b/front/php/templates/header.php index 2ed8899a..bec70142 100755 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -268,7 +268,7 @@ function getParam(targetId, key) { $.get('php/server/parameters.php?action=get¶meter='+ key, function(data) { var result = data; - document.getElementById(targetId).innerHTML = result; + document.getElementById(targetId).innerHTML = result.replaceAll('"', ''); }); }