|
|
|
@ -6,6 +6,8 @@ import (
|
|
|
|
|
"os/exec"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/shirou/gopsutil/common"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
|
|
|
|
@ -16,6 +18,7 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
|
|
|
|
|
|
|
|
|
|
lines := strings.Split(string(out), "\n")
|
|
|
|
|
ret := make([]NetIOCountersStat, 0, len(lines)-1)
|
|
|
|
|
exists := make([]string, 0, len(ret))
|
|
|
|
|
|
|
|
|
|
for _, line := range lines {
|
|
|
|
|
values := strings.Fields(line)
|
|
|
|
@ -23,6 +26,12 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
|
|
|
|
|
// skip first line
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if common.StringContains(exists, values[0]) {
|
|
|
|
|
// skip if already get
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
exists = append(exists, values[0])
|
|
|
|
|
|
|
|
|
|
base := 1
|
|
|
|
|
// sometimes Address is ommitted
|
|
|
|
|
if len(values) < 11 {
|
|
|
|
|