File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -674,14 +674,16 @@ func (m *Master) handleInfo(w http.ResponseWriter, r *http.Request) {
674674// getLinuxSysInfo 获取Linux系统信息
675675func getLinuxSysInfo () (cpu , ram int ) {
676676 if runtime .GOOS != "linux" {
677- return 0 , 0
677+ return - 1 , - 1
678678 }
679679
680680 // CPU使用率:解析/proc/loadavg
681681 if data , err := os .ReadFile ("/proc/loadavg" ); err == nil {
682682 if fields := strings .Fields (string (data )); len (fields ) > 0 {
683683 if load , err := strconv .ParseFloat (fields [0 ], 64 ); err == nil {
684684 cpu = min (int (load * 100 ), 100 )
685+ } else {
686+ cpu = - 1
685687 }
686688 }
687689 }
@@ -699,6 +701,8 @@ func getLinuxSysInfo() (cpu, ram int) {
699701 }
700702 if memTotal > 0 {
701703 ram = min (int ((memTotal - memFree )* 100 / memTotal ), 100 )
704+ } else {
705+ ram = - 1
702706 }
703707 }
704708
You can’t perform that action at this time.
0 commit comments