logs fixes
This commit is contained in:
@@ -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"
|
[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"
|
[screen2]: ./docs/img/events.png "Screen 2"
|
||||||
[screen3]: ./docs/img/presence.png "Screen 3"
|
[screen3]: ./docs/img/presence.png "Screen 3"
|
||||||
[screen4]: ./docs/img/maintenance.png "Screen 4"
|
[screen4]: ./docs/img/maintenance.png "Screen 4"
|
||||||
|
|||||||
@@ -506,7 +506,7 @@ def main ():
|
|||||||
# proceed if 1 minute passed
|
# proceed if 1 minute passed
|
||||||
if last_run + timedelta(minutes=1) < time_now :
|
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
|
last_run = time_now
|
||||||
|
|
||||||
reporting = False
|
reporting = False
|
||||||
@@ -552,7 +552,7 @@ def main ():
|
|||||||
# Final message
|
# Final message
|
||||||
if cycle != "":
|
if cycle != "":
|
||||||
action = str(cycle)
|
action = str(cycle)
|
||||||
if cycle == "1":
|
if action == "1":
|
||||||
action = "network_scan"
|
action = "network_scan"
|
||||||
file_print('[', time_now.replace (microsecond=0), '] Last action: ', action)
|
file_print('[', time_now.replace (microsecond=0), '] Last action: ', action)
|
||||||
cycle = ""
|
cycle = ""
|
||||||
@@ -575,7 +575,7 @@ def check_internet_IP ():
|
|||||||
reporting = False
|
reporting = False
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
updateState("Scanning: Internet IP")
|
updateState("Scan: Internet IP")
|
||||||
file_print('[', startTime, '] Check Internet IP:')
|
file_print('[', startTime, '] Check Internet IP:')
|
||||||
|
|
||||||
# Get Internet IP
|
# Get Internet IP
|
||||||
@@ -744,18 +744,18 @@ def check_IP_format (pIP):
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def cleanup_database ():
|
def cleanup_database ():
|
||||||
# Header
|
# Header
|
||||||
updateState("Maintenance: DB cleanup")
|
updateState("Upkeep: Clean DB")
|
||||||
file_print('[', startTime, '] Cleanup Database:' )
|
file_print('[', startTime, '] Upkeep Database:' )
|
||||||
|
|
||||||
openDB()
|
openDB()
|
||||||
|
|
||||||
# Cleanup Online History
|
# 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')")
|
sql.execute ("DELETE FROM Online_History WHERE Scan_Date <= date('now', '-1 day')")
|
||||||
file_print(' Optimize Database')
|
file_print(' Optimize Database')
|
||||||
|
|
||||||
# Cleanup Events
|
# 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')")
|
sql.execute ("DELETE FROM Events WHERE eve_DateTime <= date('now', '-"+str(DAYS_TO_KEEP_EVENTS)+" day')")
|
||||||
|
|
||||||
# Shrink DB
|
# Shrink DB
|
||||||
@@ -769,11 +769,11 @@ def cleanup_database ():
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def update_devices_MAC_vendors (pArg = ''):
|
def update_devices_MAC_vendors (pArg = ''):
|
||||||
# Header
|
# Header
|
||||||
updateState("Maintenance: Update HW Vendors")
|
updateState("Upkeep: Vendors")
|
||||||
file_print('[', startTime, '] Update HW Vendors:' )
|
file_print('[', startTime, '] Upkeep - Update HW Vendors:' )
|
||||||
|
|
||||||
# Update vendors DB (iab oui)
|
# 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', ' > ', logPath + '/update_vendors.log', '2>&1']
|
||||||
update_args = ['sh', PIALERT_BACK_PATH + '/update_vendors.sh', pArg]
|
update_args = ['sh', PIALERT_BACK_PATH + '/update_vendors.sh', pArg]
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@ def update_devices_MAC_vendors (pArg = ''):
|
|||||||
notFound = 0
|
notFound = 0
|
||||||
|
|
||||||
# All devices loop
|
# All devices loop
|
||||||
file_print('\nSearching devices vendor')
|
file_print(' Searching devices vendor')
|
||||||
openDB()
|
openDB()
|
||||||
for device in sql.execute ("SELECT * FROM Devices") :
|
for device in sql.execute ("SELECT * FROM Devices") :
|
||||||
# Search vendor in HW Vendors DB
|
# Search vendor in HW Vendors DB
|
||||||
@@ -889,7 +889,7 @@ def scan_network ():
|
|||||||
# # devtest end
|
# # devtest end
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
updateState("Scanning: Network")
|
updateState("Scan: Network")
|
||||||
file_print('[', startTime, '] Scan Devices:' )
|
file_print('[', startTime, '] Scan Devices:' )
|
||||||
file_print(' ScanCycle:', cycle)
|
file_print(' ScanCycle:', cycle)
|
||||||
|
|
||||||
@@ -1942,45 +1942,45 @@ def email_reporting ():
|
|||||||
|
|
||||||
# Send Mail
|
# Send Mail
|
||||||
if json_internet != [] or json_new_devices != [] or json_down_devices != [] or json_events != []:
|
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'):
|
if REPORT_MAIL and check_config('email'):
|
||||||
updateState("Sending: Email")
|
updateState("Send: Email")
|
||||||
file_print(' Sending report by Email')
|
file_print(' Sending report by Email')
|
||||||
send_email (mail_text, mail_html)
|
send_email (mail_text, mail_html)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip mail')
|
file_print(' Skip mail')
|
||||||
if REPORT_APPRISE and check_config('apprise'):
|
if REPORT_APPRISE and check_config('apprise'):
|
||||||
updateState("Sending: Apprise")
|
updateState("Send: Apprise")
|
||||||
file_print(' Sending report by Apprise')
|
file_print(' Sending report by Apprise')
|
||||||
send_apprise (mail_html)
|
send_apprise (mail_html)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip Apprise')
|
file_print(' Skip Apprise')
|
||||||
if REPORT_WEBHOOK and check_config('webhook'):
|
if REPORT_WEBHOOK and check_config('webhook'):
|
||||||
updateState("Sending: Webhook")
|
updateState("Send: Webhook")
|
||||||
file_print(' Sending report by Webhook')
|
file_print(' Sending report by Webhook')
|
||||||
send_webhook (json_final, mail_text)
|
send_webhook (json_final, mail_text)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip webhook')
|
file_print(' Skip webhook')
|
||||||
if REPORT_NTFY and check_config('ntfy'):
|
if REPORT_NTFY and check_config('ntfy'):
|
||||||
updateState("Sending: NTFY")
|
updateState("Send: NTFY")
|
||||||
file_print(' Sending report by NTFY')
|
file_print(' Sending report by NTFY')
|
||||||
send_ntfy (mail_text)
|
send_ntfy (mail_text)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip NTFY')
|
file_print(' Skip NTFY')
|
||||||
if REPORT_PUSHSAFER and check_config('pushsafer'):
|
if REPORT_PUSHSAFER and check_config('pushsafer'):
|
||||||
updateState("Sending: PUSHSAFER")
|
updateState("Send: PUSHSAFER")
|
||||||
file_print(' Sending report by PUSHSAFER')
|
file_print(' Sending report by PUSHSAFER')
|
||||||
send_pushsafer (mail_text)
|
send_pushsafer (mail_text)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip PUSHSAFER')
|
file_print(' Skip PUSHSAFER')
|
||||||
# Update MQTT entities
|
# Update MQTT entities
|
||||||
if REPORT_MQTT and check_config('mqtt'):
|
if REPORT_MQTT and check_config('mqtt'):
|
||||||
updateState("Sending: MQTT")
|
updateState("Send: MQTT")
|
||||||
file_print(' Establishing MQTT thread')
|
file_print(' Establishing MQTT thread')
|
||||||
mqtt_start()
|
mqtt_start()
|
||||||
else :
|
else :
|
||||||
file_print(' Skip MQTT')
|
file_print(' Skip MQTT')
|
||||||
else :
|
else :
|
||||||
file_print(' No changes to report')
|
file_print(' No changes to report')
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
🐳 [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)
|
||||||
|
|
||||||
<a href="https://raw.githubusercontent.com/jokob-sk/Pi.Alert/main/docs/img/1_devices.jpg" target="_blank">
|
<a href="https://raw.githubusercontent.com/jokob-sk/Pi.Alert/main/docs/img/devices_split.png" target="_blank">
|
||||||
<img src="https://raw.githubusercontent.com/jokob-sk/Pi.Alert/main/docs/img/1_devices.jpg" width="300px" />
|
<img src="https://raw.githubusercontent.com/jokob-sk/Pi.Alert/main/docs/img/devices_split.png" width="300px" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://raw.githubusercontent.com/jokob-sk/Pi.Alert/main/docs/img/2_4_network.png" target="_blank">
|
<a href="https://raw.githubusercontent.com/jokob-sk/Pi.Alert/main/docs/img/network.png" target="_blank">
|
||||||
<img src="https://raw.githubusercontent.com/jokob-sk/Pi.Alert/main/docs/img/2_4_network.png" width="320px" />
|
<img src="https://raw.githubusercontent.com/jokob-sk/Pi.Alert/main/docs/img/network.png" width="300px" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,36 @@
|
|||||||
font-family: 'Courier New', monospace;
|
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
|
.logs-small
|
||||||
{
|
{
|
||||||
height: 100px;
|
height: 100px;
|
||||||
}
|
}
|
||||||
|
.log-file
|
||||||
|
{
|
||||||
|
width: 145px;
|
||||||
|
display: inline-grid;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
.log-purge
|
||||||
|
{
|
||||||
|
width: 90px;
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
.span-padding
|
.span-padding
|
||||||
{
|
{
|
||||||
padding:10px;
|
padding:10px;
|
||||||
|
|||||||
@@ -346,55 +346,79 @@ if (submit && isset($_POST['skinselector_set'])) {
|
|||||||
<!-- ---------------------------Logging-------------------------------------------- -->
|
<!-- ---------------------------Logging-------------------------------------------- -->
|
||||||
<div class="tab-pane" id="tab_Logging">
|
<div class="tab-pane" id="tab_Logging">
|
||||||
<div class="db_info_table">
|
<div class="db_info_table">
|
||||||
<div class="db_info_table_row">
|
<div class="log-area">
|
||||||
<div class="db_tools_table_cell_a" style="">
|
<div class="row logs-row">
|
||||||
<div><label>pialert.log</label><span class="span-padding"><a href="./log/pialert.log"><i class="fa fa-download"></i> </a></span></div>
|
|
||||||
<div><button class="btn btn-primary" onclick="logManage('pialert.log','cleanLog')"><?php echo lang('Gen_Purge');?></button></div>
|
|
||||||
</div>
|
|
||||||
<div class="db_tools_table_cell_b">
|
|
||||||
<textarea id="pialert_log" class="logs" cols="70" rows="10" readonly ><?php echo file_get_contents( "./log/pialert.log" ); ?>
|
<textarea id="pialert_log" class="logs" cols="70" rows="10" readonly ><?php echo file_get_contents( "./log/pialert.log" ); ?>
|
||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row logs-row" >
|
||||||
<div class="db_info_table_row">
|
<div>
|
||||||
<div class="db_tools_table_cell_a" style="">
|
<div class="log-file">pialert.log</div><span class="span-padding"><a href="./log/pialert.log" target="_blank"><i class="fa fa-download"></i> </a></span>
|
||||||
<div><label>pialert_front.log</label><span class="span-padding"><a href="./log/pialert_front.log"><i class="fa fa-download"></i> </a></span></div>
|
<div class="log-purge">
|
||||||
<div><button class="btn btn-primary" onclick="logManage('pialert_front.log','cleanLog')"><?php echo lang('Gen_Purge');?></button></div>
|
<button class="btn btn-primary" onclick="logManage('pialert.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="db_tools_table_cell_b">
|
</div>
|
||||||
|
<div class="log-area">
|
||||||
|
<div class="row logs-row">
|
||||||
<textarea id="pialert_front_log" class="logs" cols="70" rows="10" wrap='off' readonly><?php echo file_get_contents( "./log/pialert_front.log" ); ?>
|
<textarea id="pialert_front_log" class="logs" cols="70" rows="10" wrap='off' readonly><?php echo file_get_contents( "./log/pialert_front.log" ); ?>
|
||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row logs-row" >
|
||||||
<div class="db_info_table_row">
|
<div>
|
||||||
<div class="db_tools_table_cell_a" style="">
|
<div class="log-file">pialert_front.log</div><span class="span-padding"><a href="./log/pialert_front.log"><i class="fa fa-download"></i> </a></span>
|
||||||
<div><label>IP_changes.log</label><span class="span-padding"><a href="./log/IP_changes.log"><i class="fa fa-download"></i> </a></span></div>
|
<div class="log-purge">
|
||||||
<div><button class="btn btn-primary" onclick="logManage('IP_changes.log','cleanLog')"><?php echo lang('Gen_Purge');?></button></div>
|
<button class="btn btn-primary" onclick="logManage('pialert_front.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="db_tools_table_cell_b">
|
</div>
|
||||||
|
<div class="log-area">
|
||||||
|
|
||||||
|
<div class="row logs-row">
|
||||||
<textarea id="IP_changes_log" class="logs logs-small" cols="70" rows="10" readonly><?php echo file_get_contents( "./log/IP_changes.log" ); ?>
|
<textarea id="IP_changes_log" class="logs logs-small" cols="70" rows="10" readonly><?php echo file_get_contents( "./log/IP_changes.log" ); ?>
|
||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row logs-row" >
|
||||||
<div class="db_info_table_row">
|
<div>
|
||||||
<div class="db_tools_table_cell_a" style="">
|
<div class="log-file">IP_changes.log</div><span class="span-padding"><a href="./log/IP_changes.log"><i class="fa fa-download"></i> </a></span>
|
||||||
<div><label>stdout.log</label><span class="span-padding"><a href="./log/stdout.log"><i class="fa fa-download"></i> </a></span></div>
|
<div class="log-purge">
|
||||||
<div><button class="btn btn-primary" onclick="logManage('stdout.log','cleanLog')"><?php echo lang('Gen_Purge');?></button></div>
|
<button class="btn btn-primary" onclick="logManage('IP_changes.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="db_tools_table_cell_b">
|
|
||||||
|
</div>
|
||||||
|
<div class="log-area">
|
||||||
|
<div class="row logs-row">
|
||||||
<textarea id="stdout_log" class="logs logs-small" cols="70" rows="10" wrap='off' readonly><?php echo file_get_contents( "./log/stdout.log" ); ?>
|
<textarea id="stdout_log" class="logs logs-small" cols="70" rows="10" wrap='off' readonly><?php echo file_get_contents( "./log/stdout.log" ); ?>
|
||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row logs-row" >
|
||||||
|
<div>
|
||||||
|
<div class="log-file">stdout.log</div><span class="span-padding"><a href="./log/stdout.log"><i class="fa fa-download"></i> </a></span>
|
||||||
|
<div class="log-purge">
|
||||||
|
<button class="btn btn-primary" onclick="logManage('stdout.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="db_info_table_row">
|
<div class="log-area">
|
||||||
<div class="db_tools_table_cell_a" style="">
|
<div class="row logs-row">
|
||||||
<div><label>stderr.log</label><span class="span-padding"><a href="./log/stderr.log"><i class="fa fa-download"></i> </a></span></div>
|
|
||||||
<div><button class="btn btn-primary" onclick="logManage('stderr.log','cleanLog')"><?php echo lang('Gen_Purge');?></button></div>
|
|
||||||
</div>
|
|
||||||
<div class="db_tools_table_cell_b">
|
|
||||||
<textarea id="stderr_log" class="logs logs-small" cols="70" rows="10" wrap='off' readonly><?php echo file_get_contents( "./log/stderr.log" ); ?>
|
<textarea id="stderr_log" class="logs logs-small" cols="70" rows="10" wrap='off' readonly><?php echo file_get_contents( "./log/stderr.log" ); ?>
|
||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row logs-row" >
|
||||||
|
<div>
|
||||||
|
<div class="log-file">stderr.log</div><span class="span-padding"><a href="./log/stderr.log"><i class="fa fa-download"></i> </a></span>
|
||||||
|
<div class="log-purge">
|
||||||
|
<button class="btn btn-primary" onclick="logManage('stderr.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ function getParam(targetId, key) {
|
|||||||
$.get('php/server/parameters.php?action=get¶meter='+ key, function(data) {
|
$.get('php/server/parameters.php?action=get¶meter='+ key, function(data) {
|
||||||
var result = data;
|
var result = data;
|
||||||
|
|
||||||
document.getElementById(targetId).innerHTML = result;
|
document.getElementById(targetId).innerHTML = result.replaceAll('"', '');
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user