diff --git a/back/pialert.py b/back/pialert.py index 8fa32594..21ae38ee 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -711,12 +711,15 @@ def print_scan_stats (): sql.execute("SELECT * FROM Devices") History_All = sql.fetchall() History_All_Devices = len(History_All) + sql.execute("SELECT * FROM Devices WHERE dev_Archived = 1") + History_Archived = sql.fetchall() + History_Archived_Devices = len(History_Archived) sql.execute("""SELECT * FROM CurrentScan WHERE cur_ScanCycle = ? """, (cycle,)) History_Online = sql.fetchall() History_Online_Devices = len(History_Online) - History_Offline_Devices = History_All_Devices - History_Online_Devices - sql.execute ("INSERT INTO Online_History (Scan_Date, Online_Devices, Down_Devices, All_Devices) "+ - "VALUES ( ?, ?, ?, ?)", (startTime, History_Online_Devices, History_Offline_Devices, History_All_Devices ) ) + History_Offline_Devices = History_All_Devices - History_Archived_Devices - History_Online_Devices + sql.execute ("INSERT INTO Online_History (Scan_Date, Online_Devices, Down_Devices, All_Devices, Archived_Devices, ScanCycle) "+ + "VALUES ( ?, ?, ?, ?, ?, ?)", (startTime, History_Online_Devices, History_Offline_Devices, History_All_Devices, History_Archived_Devices, cycle ) ) #------------------------------------------------------------------------------- def create_new_devices (): @@ -961,7 +964,7 @@ def update_devices_data_from_scan (): # New Apple devices -> Cycle 15 print_log ('Update devices - 6 Cycle for Apple devices') - sql.execute ("""UPDATE Devices SET dev_ScanCycle = 15 + sql.execute ("""UPDATE Devices SET dev_ScanCycle = 1 WHERE dev_FirstConnection = ? AND UPPER(dev_Vendor) LIKE '%APPLE%' """, (startTime,) ) diff --git a/front/devices.php b/front/devices.php index ec388348..5cba1fbd 100644 --- a/front/devices.php +++ b/front/devices.php @@ -118,7 +118,8 @@ var pia_js_online_history_time = []; var pia_js_online_history_ondev = []; var pia_js_online_history_dodev = []; - pia_draw_graph_online_history(pia_js_online_history_time, pia_js_online_history_ondev, pia_js_online_history_dodev); + var pia_js_online_history_ardev = []; + pia_draw_graph_online_history(pia_js_online_history_time, pia_js_online_history_ondev, pia_js_online_history_dodev, pia_js_online_history_ardev); diff --git a/front/js/graph_online_history.js b/front/js/graph_online_history.js index 65d672bd..268acdc4 100644 --- a/front/js/graph_online_history.js +++ b/front/js/graph_online_history.js @@ -1,24 +1,30 @@ -function pia_draw_graph_online_history(pia_js_graph_online_history_time, pia_js_graph_online_history_ondev, pia_js_graph_online_history_dodev) { +function pia_draw_graph_online_history(pia_js_graph_online_history_time, pia_js_graph_online_history_ondev, pia_js_graph_online_history_dodev, pia_js_graph_online_history_ardev) { var xValues = pia_js_graph_online_history_time; new Chart("OnlineChart", { type: "bar", data: { labels: xValues, datasets: [{ - label: 'Online Devices', + label: 'Online', data: pia_js_graph_online_history_ondev, - borderColor: "#00a65a", + borderColor: "rgba(0, 166, 89)", fill: true, backgroundColor: "rgba(0, 166, 89, .6)", pointStyle: 'circle', pointRadius: 3, pointHoverRadius: 3 }, { - label: 'Offline/Down Devices', + label: 'Offline/Down', data: pia_js_graph_online_history_dodev, - borderColor: "#dd4b39", + borderColor: "rgba(222, 74, 56)", fill: true, backgroundColor: "rgba(222, 74, 56, .6)", + }, { + label: 'Archived', + data: pia_js_graph_online_history_ardev, + borderColor: "rgba(220,220,220)", + fill: true, + backgroundColor: "rgba(220,220,220, .6)", }] }, options: { diff --git a/front/maintenance.php b/front/maintenance.php index 3dbf210a..093fbedb 100644 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -373,7 +373,6 @@ if (submit && isset($_POST['langselector_set'])) { diff --git a/install/pialert.cron b/install/pialert.cron index 9c479ee3..a01b5861 100644 --- a/install/pialert.cron +++ b/install/pialert.cron @@ -10,7 +10,6 @@ TZ=TIMEZONE 0 3 * * 1 python /home/pi/pialert/back/pialert.py update_vendors >/home/pi/pialert/log/pialert.vendors.log 2>&1 -*/1 * * * * python /home/pi/pialert/back/pialert.py internet_IP >/home/pi/pialert/log/pialert.IP.log 2>&1 +*/3 * * * * python /home/pi/pialert/back/pialert.py internet_IP >/home/pi/pialert/log/pialert.IP.log 2>&1 */5 * * * * python /home/pi/pialert/back/pialert.py 1 >/home/pi/pialert/log/pialert.1.log 2>&1 -*/15 * * * * python /home/pi/pialert/back/pialert.py 15 >/home/pi/pialert/log/pialert.15.log 2>&1 */30 * * * * cp /home/pi/pialert/db/pialert.db /home/pi/pialert/config/pialert.db_bak diff --git a/install/pialert_patch_DB.sh b/install/pialert_patch_DB.sh new file mode 100755 index 00000000..fd99ca26 --- /dev/null +++ b/install/pialert_patch_DB.sh @@ -0,0 +1,5 @@ +#!/bin/sh +echo "Create backup before insert new table" +cp ../db/pialert.db ../db/pialert.db.bak +echo "Insert new table 'Online_History' to pialert.db" +sqlite3 ../db/pialert.db "CREATE TABLE 'Online_History' ('Index' INTEGER, 'Scan_Date' TEXT, 'Online_Devices' INTEGER, 'Down_Devices' INTEGER, 'All_Devices' INTEGER, 'Archived_Devices' INTEGER, PRIMARY KEY('Index' AUTOINCREMENT));" diff --git a/tar/pialert_latest.tar b/tar/pialert_latest.tar new file mode 100644 index 00000000..5a86273c Binary files /dev/null and b/tar/pialert_latest.tar differ