I am using Raspberry Pi to selfhost many things and looking for ways to track my data usage (what is the total transfer over period of months). So that I can choose right plan for my broadband connection.
I just have a cron job that runs "ifconfig | logger" once a week. When I want to know how much data has been sent or received, I subtract the RX bytes or TX bytes from the appropriately timestamped entries and divide by the time difference. Easy-peasy.