niujiuru 3 недель назад
Родитель
Сommit
d03b866266

+ 9 - 7
web-ui.service/page1_handler.go

@@ -246,19 +246,21 @@ func systemLoadAverageHandler(w http.ResponseWriter, r *http.Request) {
 
 	fields := strings.Fields(string(data))
 
-	if len(fields) < 3 {
+	if len(fields) < 4 {
 		http.Error(w, "invalid /proc/loadavg", http.StatusInternalServerError)
 		return
 	}
 
 	resp := struct {
-		Load1m  string `json:"load1m"`
-		Load5m  string `json:"load5m"`
-		Load15m string `json:"load15m"`
+		Load1m   string `json:"load1m"`
+		Load5m   string `json:"load5m"`
+		Load15m  string `json:"load15m"`
+		RunQueue string `json:"runQueue"`
 	}{
-		Load1m:  formatLoad(fields[0]),
-		Load5m:  formatLoad(fields[1]),
-		Load15m: formatLoad(fields[2]),
+		Load1m:   formatLoad(fields[0]),
+		Load5m:   formatLoad(fields[1]),
+		Load15m:  formatLoad(fields[2]),
+		RunQueue: fields[3],
 	}
 
 	w.Header().Set("Content-Type", "application/json")

+ 5 - 0
web-ui.service/web/pages/page1.html

@@ -45,6 +45,11 @@
           <span class="info-name">系统15分钟负载</span>
           <span class="info-value" id="load15m">--</span>
         </div>
+
+        <div class="info-item">
+          <span class="info-name">系统待运行任务</span>
+          <span class="info-value" id="runQueue">--</span>
+        </div>
       </div>
     </div>
 

+ 8 - 0
web-ui.service/web/static/js/app.js

@@ -56,6 +56,14 @@ async function fetchIMEI() {
   }
 }
 
+function setText(id, value)
+{
+  const el = document.getElementById(id);
+  if (el) {
+    el.textContent = value ?? "--";
+  }
+}
+
 function loadIMEI() {
     fetchIMEI();
 }

+ 20 - 1
web-ui.service/web/static/js/page1.js

@@ -3,6 +3,7 @@ let memChart       = null;
 let diskChart      = null;
 let sysStatusTimer = null;
 let resizeHandler  = null;
+let page1Active    = false;
 
 function getSystemInfo(){
   fetch("/api/system/info")
@@ -109,16 +110,24 @@ function getLoadInfo(){
       return r.json();
     })
     .then(data => {
+      if(!page1Active){
+        return;
+      }
       document.getElementById("load1m").textContent = data.load1m || "--";
       document.getElementById("load5m").textContent = data.load5m || "--";
       document.getElementById("load15m").textContent = data.load15m || "--";
+      document.getElementById("runQueue").textContent = data.runQueue || "--";
     })
     .catch(e => {
+      if(!page1Active){
+        return;
+      }
       console.error("network status failed:", e);
 
       document.getElementById("load1m").textContent = "--";
       document.getElementById("load5m").textContent = "--";
       document.getElementById("load15m").textContent = "--";
+      document.getElementById("runQueue").textContent = "--";
     });
 }
 
@@ -132,6 +141,9 @@ function getServiceInfo(){
       return r.json();
     })
     .then(data => {
+      if(!page1Active){
+        return;
+      }
       document.getElementById("var1").textContent = data.var1 || "--";
       document.getElementById("var2").textContent = data.var2 || "--";
       document.getElementById("var3").textContent = data.var3 || "--";
@@ -150,7 +162,10 @@ function getServiceInfo(){
       document.getElementById("var88").textContent = data.var88 || "--";
     })
     .catch(e => {
-      console.error("getAllServiceStatus status failed:", e);
+      if(!page1Active){
+        return;
+      }
+      console.error("getAllServiceStatus() failed:", e);
 
       document.getElementById("var1").textContent = "--";
       document.getElementById("var2").textContent = "--";
@@ -199,6 +214,8 @@ function resizeSysCharts(){
 }
 
 function initPage1(){
+  page1Active = true;
+
   cpuChart=echarts.init(document.getElementById("cpu-chart"));
   memChart=echarts.init(document.getElementById("mem-chart"));
   diskChart=echarts.init(document.getElementById("disk-chart"));
@@ -246,6 +263,8 @@ function initPage1(){
 }
 
 function exitPage1(){
+  page1Active = false;
+
   stopSysStatusRefresh();
 
   if(resizeHandler){

+ 1 - 1
web-ui.service/web/static/js/page2.js

@@ -189,7 +189,7 @@ function getNetworkStatus() {
       document.getElementById("var5").textContent = data.var5 || "--";
     })
     .catch(e => {
-      console.error("network status failed:", e);
+      console.error("getNetworkStatus() failed:", e);
 
       document.getElementById("var1").textContent = "--";
       document.getElementById("var2").textContent = "--";

+ 1 - 1
web-ui.service/web/static/js/page3.js

@@ -130,7 +130,7 @@ function getTimeStatus() {
       document.getElementById("var6").textContent = data.var6 || "--";
     })
     .catch(e => {
-      console.error("time status failed:", e);
+      console.error("getTimeStatus() failed:", e);
 
       document.getElementById("var1").textContent = "--";
       document.getElementById("var2").textContent = "--";

+ 1 - 1
web-ui.service/web/static/js/page4.js

@@ -127,7 +127,7 @@ function getGnssStatus() {
       document.getElementById("var3").textContent = data.var3 || "--";
     })
     .catch(e => {
-      console.error("gnss status failed:", e);
+      console.error("getGnssStatus() failed:", e);
 
       document.getElementById("var1").textContent = "--";
       document.getElementById("var2").textContent = "--";

+ 1 - 1
web-ui.service/web_handler.go

@@ -154,7 +154,7 @@ func serviceLogHandler(w http.ResponseWriter, r *http.Request) {
 		"-u",
 		unit,
 		"-n",
-		"50",
+		"10",
 		"--no-pager",
 		"-q",
 		"-o",