From 74d282435b30876877e49c59d56aef8924cbd7b6 Mon Sep 17 00:00:00 2001 From: Daniel Ding Date: Sun, 11 Jan 2026 20:46:34 +0800 Subject: [PATCH] fix: pretty bytes with Tb. --- pkg/libol/nl_linux.go | 2 +- pkg/libol/utils.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/libol/nl_linux.go b/pkg/libol/nl_linux.go index c4f560f..9a14761 100755 --- a/pkg/libol/nl_linux.go +++ b/pkg/libol/nl_linux.go @@ -210,7 +210,7 @@ func ListPhyLinks() []Device { State: state, Drop: attr.Statistics.RxDropped, Recv: attr.Statistics.RxBytes, - Send: attr.Statistics.TxPackets, + Send: attr.Statistics.TxBytes, Type: t, }) } diff --git a/pkg/libol/utils.go b/pkg/libol/utils.go index 810081f..d4eac34 100755 --- a/pkg/libol/utils.go +++ b/pkg/libol/utils.go @@ -248,7 +248,11 @@ func PrettyBytes(b uint64) string { return fmt.Sprintf("%d.%02dMb", m, d) } g, d := split(m, 1024) - return fmt.Sprintf("%d.%02dGb", g, d) + if g < 1024 { + return fmt.Sprintf("%d.%02dGb", g, d) + } + t, d := split(g, 1024) + return fmt.Sprintf("%d.%02dTb", t, d) } func GetIPAddr(addr string) string {