Browse Source

Fixed linux netstat bug

Toby Chui 3 years ago
parent
commit
d4e7cfac00
1 changed files with 4 additions and 4 deletions
  1. 4 4
      mod/network/netstat/netstat.go

+ 4 - 4
mod/network/netstat/netstat.go

@@ -33,7 +33,7 @@ func HandleGetNetworkInterfaceStats(w http.ResponseWriter, r *http.Request) {
 	common.SendJSONResponse(w, string(js))
 }
 
-//Get network interface stats, return rx_byte, tx_byte and error if any
+//Get network interface stats, return accumulated rx bits, tx bits and error if any
 func GetNetworkInterfaceStats() (int64, int64, error) {
 	if runtime.GOOS == "windows" {
 		cmd := exec.Command("wmic", "path", "Win32_PerfRawData_Tcpip_NetworkInterface", "Get", "BytesReceivedPersec,BytesSentPersec,BytesTotalPersec")
@@ -106,11 +106,11 @@ func GetNetworkInterfaceStats() (int64, int64, error) {
 					txSum += int64(txBytesInt)
 				}
 			}
-			
-			
+
 		}
 
-		return rxSum, txSum, nil
+		//Return value as bits
+		return rxSum * 8, txSum * 8, nil
 	}
 
 	return 0, 0, errors.New("Platform not supported")