From 6c055d08b0853e13157aead2f78e986fe515c804 Mon Sep 17 00:00:00 2001 From: Jrohy Date: Mon, 21 Dec 2020 09:15:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0TCP/UDP=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=95=B0=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/controller/common.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/web/controller/common.go b/web/controller/common.go index a323a1ad..a1948d0e 100644 --- a/web/controller/common.go +++ b/web/controller/common.go @@ -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 }