vnstat – Error: Unable to read database

Error: Unable to read database "/var/lib/vnstat/eth0": No such file or directory

This error will appear when vnstat is not configured to the correct netwrork interface. You can check what interface your device is using with ifconfig:

$ ifconfig
enp3s0: flags=4163 mtu 1500
...

And to make sure your vnstat is monitoring your identified network interface you can check for the database files located in: /var/lib/vnstat/

$ ls /var/lib/vnstat
enp3s0 wlp2s0

Now you just need to add it to your vnstat config. You could simply edit the default config file located at /etc/vnstat.conf which would apply globally. However it is recommended to create a local config for your user. Copy the global config into your home directory like so:

$ cp /etc/vnstat.conf ~/.vnstatrc

And update the default database to your selected network interface:

# default interface
Interface "enp3s0"

Save and you should be able to run vnstat and check your bandwidth stats.

$ vnstat -d
enp3s0 / daily

     day         rx      |     tx      |    total    |   avg. rate
 ------------------------+-------------+-------------+---------------
 07/08/2019    61.04 MiB |    6.05 MiB |   67.09 MiB |    6.51 kbit/s
 07/09/2019    25.36 MiB |  152.33 MiB |  177.69 MiB |   17.25 kbit/s
 07/10/2019    10.38 MiB |    2.12 MiB |   12.51 MiB |    2.38 kbit/s
 ------------------------+-------------+-------------+---------------
 estimated        19 MiB |       3 MiB |      22 MiB |

Resources

Ubuntu 16.04 LTS UI and/or Windows freezes with mouse and keyboard working

Ever since upgrading my PC hardware (graphics card) to Nvidia 970 and 1070 GTX I have been plagued with Ubuntu’s Display Manager constantly (and seemingly) randomly freezing. It was also occurring with Ubuntu 14.04 LTS.
The only solution I could find to combat this was to restart LightDM.

I would hit Ctrl + Alt + F1 to open up the shell and login. Then restart the lightdm service:

$ sudo service lightdm restart

This would restart the display manager and would stop the freezes occurring, for a while at least. The most annoying this was having to do this literally every time I booted or logged in.

After trying fresh installs, Unity tweaking and other ‘fixes‘ I finally made the transition to Debian 9 and the default Gnome 3 window manager. And to my delight it appears the problem has gone away!

I will be sticking with Debian from now on (at least until I upgrade hardware again).