Skip to content

Commit

Permalink
添加TCP/UDP连接数统计
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Dec 21, 2020
1 parent f37223b commit 6c055d0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions web/controller/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,20 @@ func ServerInfo() *ResponseBody {
smInfo, _ := mem.SwapMemory()
diskInfo, _ := disk.Usage("/")
loadInfo, _ := load.Avg()
tcpCon, _ := net.Connections("tcp")
udpCon, _ := net.Connections("udp")
netCount := map[string]int{
"tcp": len(tcpCon),
"udp": len(udpCon),
}
responseBody.Data = map[string]interface{}{
"cpu": cpuPercent,
"memory": vmInfo,
"swap": smInfo,
"disk": diskInfo,
"load": loadInfo,
"speed": si,
"cpu": cpuPercent,
"memory": vmInfo,
"swap": smInfo,
"disk": diskInfo,
"load": loadInfo,
"speed": si,
"netCount": netCount,
}
return &responseBody
}

0 comments on commit 6c055d0

Please sign in to comment.