Skip to content

Commit

Permalink
filter kvm or bridge traffic statustics
Browse files Browse the repository at this point in the history
  • Loading branch information
ubuntu committed Jan 29, 2019
1 parent 48b57ff commit c253f75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions clients/client-linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def get(self):
for dev in net_dev[2:]:
dev = dev.split(':')
if "lo" in dev[0] or "tun" in dev[0] \
or "docker" in dev[0] or "veth" in dev[0] \
or "br-" in dev[0] or "vmbr" in dev[0] \
or "vnet" in dev[0]:
or "docker" in dev[0] or "veth" in dev[0] \
or "br-" in dev[0] or "vmbr" in dev[0] \
or "vnet" in dev[0] or "kube" in dev[0]:
continue
dev = dev[1].split()
avgrx += int(dev[0])
Expand Down Expand Up @@ -122,7 +122,8 @@ def liuliang():
if netinfo:
if netinfo[0][0] == 'lo' or 'tun' in netinfo[0][0] \
or 'docker' in netinfo[0][0] or 'veth' in netinfo[0][0] \
or 'br-' in netinfo[0][0] \
or 'br-' in netinfo[0][0] or 'vmbr' in netinfo[0][0] \
or 'vnet' in netinfo[0][0] or 'kube' in netinfo[0][0] \
or netinfo[0][1]=='0' or netinfo[0][9]=='0':
continue
else:
Expand Down
9 changes: 5 additions & 4 deletions clients/client-psutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def get(self):
if "lo" in name or "tun" in name \
or "docker" in name or "veth" in name \
or "br-" in name or "vmbr" in name \
or "vnet" in name:
or "vnet" in name or "kube" in name:
continue
avgrx += stats.bytes_recv
avgtx += stats.bytes_sent
Expand All @@ -89,9 +89,10 @@ def liuliang():
NET_OUT = 0
net = psutil.net_io_counters(pernic=True)
for k, v in net.items():
if k == 'lo' or 'tun' in k \
or 'br-' in k \
or 'docker' in k or 'veth' in k:
if 'lo' in k or 'tun' in k \
or 'docker' in k or 'veth' in k \
or 'br-' in k or 'vmbr' in k \
or 'vnet' in k or 'kube' in k:
continue
else:
NET_IN += v[1]
Expand Down

0 comments on commit c253f75

Please sign in to comment.