mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Add history graph to Devices and presence (in development)
- A change in the database is necessary - change scan-script (pialert.py) was changed to write more data into the database - update Chart.js to 2.9.4
This commit is contained in:
25
front/php/templates/graph.php
Normal file
25
front/php/templates/graph.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$Pia_Graph_Device_Time = array();
|
||||
$Pia_Graph_Device_All = array();
|
||||
$Pia_Graph_Device_Online = array();
|
||||
$Pia_Graph_Device_Down = array();
|
||||
$db = new SQLite3('../db/pialert.db');
|
||||
$results = $db->query('SELECT * FROM Online_History ORDER BY Scan_Date DESC LIMIT 40');
|
||||
while ($row = $results->fetchArray()) {
|
||||
$time_raw = explode(' ', $row['Scan_Date']);
|
||||
$time = explode(':', $time_raw[1]);
|
||||
array_push($Pia_Graph_Device_Time, $time[0].':'.$time[1]);
|
||||
array_push($Pia_Graph_Device_Down, $row['Down_Devices']);
|
||||
array_push($Pia_Graph_Device_All, $row['All_Devices']);
|
||||
array_push($Pia_Graph_Device_Online, $row['Online_Devices']);
|
||||
}
|
||||
function pia_graph_devices_data($Pia_Graph_Array) {
|
||||
$Pia_Graph_Array_rev = array_reverse($Pia_Graph_Array);
|
||||
foreach ($Pia_Graph_Array_rev as $result) {
|
||||
echo "'".$result."'";
|
||||
echo ",";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user