diff --git a/simpleadmin/www/cgi-bin/get_uptime b/simpleadmin/www/cgi-bin/get_uptime
new file mode 100644
index 0000000..8e27fec
--- /dev/null
+++ b/simpleadmin/www/cgi-bin/get_uptime
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Execute the uptime command and extract the uptime duration
+uptime_output=$(uptime)
+
+# Extract hours and minutes from the uptime string
+hours=$(echo "$uptime_output" | awk -F '[ :]+' '{print $6}')
+minutes=$(echo "$uptime_output" | awk -F '[ :]+' '{print $7}')
+
+# Remove comma to minutes
+minutes=$(echo $minutes | tr -d ,)
+
+# Create a text response with the uptime duration
+uptime_text="$hours hours and $minutes minutes"
+
+# if hours and minutes are 1 or 0, then remove the 's' from the end of the string
+if [ $hours -eq 1 ] || [ $hours -eq 0 ]; then
+ uptime_text=$(echo $uptime_text | sed 's/hours/hour/g')
+fi
+
+# Set header for plain text content
+echo "Content-Type: text/plain"
+echo ""
+
+# Output the text response
+echo "$uptime_text"
\ No newline at end of file
diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html
index bdfce77..7834dcf 100644
--- a/simpleadmin/www/index.html
+++ b/simpleadmin/www/index.html
@@ -56,7 +56,7 @@
SMS
-
+
Console
@@ -202,6 +202,10 @@
IPv6 |
|
+
+ | Uptime |
+ |
+
@@ -611,6 +615,7 @@
newRefreshRate: null,
refreshRate: 3,
intervalId: null,
+ uptime: "Unknown",
fetchNetworkInfo() {
this.atcmd =
'AT+QTEMP;+QUIMSLOT?;+QSPN;+CGCONTRDP=1;+QMAP="WWANIP";+QENG="servingcell";+QCAINFO';
@@ -1004,7 +1009,9 @@
// Calculate the NR bandwidth
this.bandwidth +=
- " / NR " + this.calculate_nr_bw(nr_bw).toString() + " MHz";
+ " / NR " +
+ this.calculate_nr_bw(nr_bw).toString() +
+ " MHz";
// Parse the PCIs
this.pcc_pci = lines[28].split(",")[5].replace(/"/g, "");
@@ -1197,6 +1204,18 @@
});
},
+
+ fetchUpTime() {
+ // Content-Type: text/plain
+ //
+ // 1 hour 44, minute
+ fetch("/cgi-bin/get_uptime")
+ .then((response) => response.text())
+ .then((data) => {
+ this.uptime = data;
+ });
+ },
+
updateRefreshRate() {
// Check if the refresh rate is less than 3
if (this.newRefreshRate < 3) {
@@ -1247,6 +1266,8 @@
this.internetConnection = "Disconnected";
});
+ this.fetchUpTime();
+
this.lastUpdate = new Date().toLocaleString();
console.log("Initialized");
@@ -1273,6 +1294,8 @@
this.internetConnection = "Disconnected";
});
+ this.fetchUpTime();
+
this.lastUpdate = new Date().toLocaleString();
console.log("Refreshed");
}, this.refreshRate * 1000);