]> Sergey Matveev's repositories - godwmstat.git/commitdiff
Shorter NIC names master
authorSergey Matveev <stargrave@stargrave.org>
Sun, 24 Sep 2023 12:46:57 +0000 (15:46 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 24 Sep 2023 12:46:57 +0000 (15:46 +0300)
main.go

diff --git a/main.go b/main.go
index 09ff208b35b07a49132cdf6b6f08ebb538ee895a..20b4d350014c95b1e8fe77d55fa008da4158fc6b 100644 (file)
--- a/main.go
+++ b/main.go
@@ -99,7 +99,7 @@ func iostat() {
        }
 }
 
-func netstat(iface string) {
+func netstat(iface, short string) {
        for cols := range bg("netstat", "-I", iface, "-n", "1") {
                if _, err := strconv.Atoi(cols[0]); err != nil {
                        continue
@@ -115,9 +115,9 @@ func netstat(iface string) {
                _ = cols[0] // pkts rx
                _ = cols[4] // pkts tx
                NetM.Lock()
-               Net[iface] = fmt.Sprintf(
+               Net[short] = fmt.Sprintf(
                        "%s:%s/%s",
-                       iface,
+                       short,
                        humanize.IBytes(uint64(ibps)),
                        humanize.IBytes(uint64(obps)),
                )
@@ -164,8 +164,8 @@ func main() {
        go top()
        go freq()
        go iostat()
-       go netstat("bridge0")
-       go netstat("ix0")
+       go netstat("bridge0", "br")
+       go netstat("ix0", "ix")
        var now time.Time
        var status string
        var cmd *exec.Cmd
@@ -174,7 +174,7 @@ func main() {
                NetM.RLock()
                status = fmt.Sprintf(
                        "[%s]  [%s %s]  [%s %s]  [%s%s %s ARC]  [%s] %s",
-                       IOs, Net["bridge0"], Net["ix0"], CPU, Freq, Swap, Mem, ARC, Flags,
+                       IOs, Net["br"], Net["ix"], CPU, Freq, Swap, Mem, ARC, Flags,
                        now.Format("2006-01-02 15:04:05"),
                )
                NetM.RUnlock()