mirror of
https://github.com/Monibuca/plugin-summary.git
synced 2025-10-12 02:10:18 +08:00
只收集指定的网卡数据,用于过滤机器上的虚拟网卡,支持正则
This commit is contained in:
@@ -158,6 +158,10 @@ func (s *ServerSummary) collect() {
|
||||
s.HardDisk.Usage = d.UsedPercent
|
||||
s.NetWork = make([]NetWorkInfo, len(nv))
|
||||
for i, n := range nv {
|
||||
if !isNetAdapter(n.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
s.NetWork[i].Name = n.Name
|
||||
s.NetWork[i].Receive = n.BytesRecv
|
||||
s.NetWork[i].Sent = n.BytesSent
|
||||
@@ -178,9 +182,9 @@ func isNetAdapter(name string) bool {
|
||||
}
|
||||
|
||||
//正则用@作正则修饰符
|
||||
if !strings.Contains(name, "@") {
|
||||
if !strings.Contains(config.NetAdapter, "@") {
|
||||
return strings.Contains(name, config.NetAdapter)
|
||||
}
|
||||
|
||||
return gregex.IsMatchString(config.NetAdapter, name)
|
||||
return gregex.IsMatchString(strings.Trim(config.NetAdapter, "@"), name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user