def getUpDiff(interface): if interface not in NET_INTERFACES: return 0 netstats = _statgrab.py_sg_get_network_io_stats() for i in netstats: if i['interface_name'] == interface: NET_LAST_U[interface] = NET_U[interface] NET_U[interface] = i['tx'] return NET_U[interface] - NET_LAST_U[interface]
def getDownDiff(interface): if interface not in NET_INTERFACES: return 0 netstats = _statgrab.py_sg_get_network_io_stats() for i in netstats: if i['interface_name'] == interface: NET_LAST_D[interface] = NET_D[interface] NET_D[interface] = i['rx'] return NET_D[interface] - NET_LAST_D[interface]
def initNetIfaces(): network_ifaces = _statgrab.py_sg_get_network_iface_stats() for i in network_ifaces: NET_INTERFACES.append(i['interface_name']) for i in NET_INTERFACES: netstats = _statgrab.py_sg_get_network_io_stats() for j in netstats: if j['interface_name'] == i: NET_D[i] = NET_LAST_D[i] = j['rx'] NET_U[i] = NET_LAST_U[i] = j['tx']