mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
cmd/auxstats: improve network device name matcher in Linux
This commit is contained in:
parent
0ac2a105ae
commit
7b0b2065fa
1 changed files with 3 additions and 1 deletions
|
@ -120,9 +120,11 @@ xnet(int first)
|
||||||
vlong totb, totp, tote, totin, totou, totinb, totoub, b, p, e, in, ou, inb, oub;
|
vlong totb, totp, tote, totin, totou, totinb, totoub, b, p, e, in, ou, inb, oub;
|
||||||
char *q;
|
char *q;
|
||||||
static int fd = -1;
|
static int fd = -1;
|
||||||
|
static Reprog *netdev = nil;
|
||||||
|
|
||||||
if(first){
|
if(first){
|
||||||
fd = open("/proc/net/dev", OREAD);
|
fd = open("/proc/net/dev", OREAD);
|
||||||
|
netdev = regcomp("^(eth[0-9]+|wlan[0-9]+|enp[0-9]+s[0-9]+f[0-9]+|wlp[0-9]+s[0-9]+)$");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +143,7 @@ xnet(int first)
|
||||||
tokens(i);
|
tokens(i);
|
||||||
if(ntok < 8+8)
|
if(ntok < 8+8)
|
||||||
continue;
|
continue;
|
||||||
if(strncmp(tok[0], "eth", 3) != 0 && strncmp(tok[0], "wlan", 4) != 0)
|
if(regexec(netdev, tok[0], nil, 0) != 1)
|
||||||
continue;
|
continue;
|
||||||
inb = atoll(tok[1]);
|
inb = atoll(tok[1]);
|
||||||
oub = atoll(tok[9]);
|
oub = atoll(tok[9]);
|
||||||
|
|
Loading…
Reference in a new issue