When running
vnstat -i [interface] --oneline
the selected interface's bandwidth usage is printed.
1;eth0;10/11/11;1.45 MiB;801 KiB;2.23 MiB;0.59 kbit/s;Oct '11;3.93 MiB;2.06 MiB;6.00 MiB;0.05 kbit/s;3.93 MiB;2.06 MiB;6.00 MiB
But to print all bandwidth usages from all interfaces, I need to run the following to get all the interfaces' name
vnstat --iflist
Then iterate through the result to store a usage result in a list
for item in result.split():
# usage = run command 'vnstat --oneline -i [interface]
# usageList.append(usage)
print ''.join(usageList)
The above script works but is running slow if there are many interfaces. How to optimize?