Truncate tops reporting to 10 and fix units with jsonversion 2

This commit is contained in:
liaralabs 2020-07-09 11:45:55 -07:00
parent 93a1157470
commit 219e29dbcb

View file

@ -269,14 +269,14 @@ def vnstat(user):
#statsa = vnstat_parse(interface, "m", "total", 0)
tops = vnstat_data(interface, "t")['interfaces'][0]['traffic'][qt]
top = []
for t in tops:
for t in tops[:10]:
date = t['date']
year = date['year']
month = calendar.month_abbr[date['month']]
day = date['day']
date = "{month} {day}, {year}".format(year=year, month=month, day=day)
rx = GetHumanReadableKB(t['rx'])
tx = GetHumanReadableKB(t['tx'])
rx = read_unit(t['rx'])
tx =read_unit(t['tx'])
top.append({"date": date, "rx": rx, "tx": tx})
columns = {"date", "rx", "tx"}
#stats = []