Browse Source

get interfaces

windows
Florian N 12 years ago
parent
commit
db8eb15dc8
  1. 6
      main/views.py
  2. 5
      usage/views.py

6
main/views.py

@ -68,8 +68,12 @@ def get_ipaddress():
data = [n for n in data if not n.startswith(('lo', '127'))]
itf = dict(zip(*[iter(data)] * 2))
data = [i.split(None, 2) for i in data]
for e in data:
if len(e) > 2:
itf = dict(zip([iter(e[0])]))
else:
itf = [e[0]]
ips = {'interface': itf, 'itfip': data}

5
usage/views.py

@ -251,7 +251,10 @@ def gettraffic(request):
cookie_traffic = {}
try:
traffic = get_traffic('eth0')
intf = get_ipaddress()
intf = intf['interface'][0]
traffic = get_traffic(intf)
except Exception:
traffic = 0

Loading…
Cancel
Save