filter localhost, docker, kvm, bridge virtual-network

pull/55/head
ubuntu 2019-01-29 14:55:12 +08:00
parent e9baa04e63
commit ec5a651276
2 changed files with 14 additions and 12 deletions

View File

@ -1,9 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding: utf-8
# Update by : https://github.com/cppla/ServerStatus
# 支持Python版本2.7 to 3.5
# 支持操作系统: Linux, OSX, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures
# 时间: 20180828
# 时间: 20190128
SERVER = "127.0.0.1"
@ -37,7 +37,7 @@ def get_memory():
for line in open('/proc/meminfo'):
match = re_parser.match(line)
if not match:
continue;
continue
key, value = match.groups(['key', 'value'])
result[key] = int(value)
@ -90,9 +90,10 @@ class Traffic:
for dev in net_dev[2:]:
dev = dev.split(':')
if dev[0].strip() == "lo" or dev[0].find("tun") > -1 \
or dev[0].find("docker") > -1 or dev[0].find("veth") > -1 \
or dev[0].find("br-") > -1:
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]:
continue
dev = dev[1].split()
avgrx += int(dev[0])

View File

@ -1,10 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding: utf-8
# Update by : https://github.com/cppla/ServerStatus
# 依赖于psutil跨平台库
# 支持Python版本2.6 to 3.5 (users of Python 2.4 and 2.5 may use 2.1.3 version)
# 支持Python版本2.7 to 3.5
# 支持操作系统: Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures
# 时间: 20180828
# 时间: 20190128
SERVER = "127.0.0.1"
PORT = 35601
@ -62,9 +62,10 @@ class Traffic:
def get(self):
avgrx = 0; avgtx = 0
for name, stats in psutil.net_io_counters(pernic=True).iteritems():
if name == "lo" or name.find("tun") > -1 \
or name.find("docker") > -1 or name.find("veth") > -1 \
or name.find("br-") > -1:
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:
continue
avgrx += stats.bytes_recv
avgtx += stats.bytes_sent