Bandwidth usage report per IP address
I created a simple python script for collecting data from mikrotik accounting (documetation) feature.
Here is my “mik_collector.py” script:
all you need to change is router_ip variable to match your router IP
after that you can run this script simply with this command:
python mik_collector.py
this will collect data from mikrotik every 5 seconds and store it in data.db sqlite3 database in the same directory as the script is.
All you need to do at mikrotik side is to enable accounting feature:
If you want to analyze your collected data you can do it with sqlite3 command from Ubuntu command prompt:
sqlite3 data.db "select * from sum_per_month order by month"
like this:
you can write your own queries, all data is stored in a table named accounting. You can share your query in the comments :)
01 May 2020
Hello, Thank you so much for this great tool. Is their any way to use with fast-track enabled ? (Best of both..) Thanks,
20 May 2020
Thanks for the tool :)
14 Sep 2021
Thx a lot.
#!/bin/sh
cesta=/home/lowprize/accounting/
echo “IP\t\t Mesic\t\t Upload\t Download” > $cesta/stats-dw.txt
echo ” \t\t \t\t MB\t MB” >> $cesta/stats-dw.txt
sqlite3 $cesta/data.db “select * from sum_per_month order by download desc” >> $cesta/stats-dw.txt
cat $cesta/stats-dw.txt| head -22 | sed ‘s/|/\t /g’
echo
echo “IP\t\t Mesic\t\t Upload\t Download” > $cesta/stats-up.txt
echo ” \t\t \t\t MB\t MB” >> $cesta/stats-up.txt
sqlite3 $cesta/data.db “select * from sum_per_month order by upload desc” >> $cesta/stats-up.txt
cat $cesta/stats-up.txt| head -22 | sed ‘s/|/\t /g’
read -p “Stiskni cokoliv” continue
21 Sep 2023
Do you have an updated script for the new Traffic Flow option in ROS 7?