VnStat Install (interface usage stats)

From PiStar Wiki
Revision as of 14:16, 30 July 2018 by MW0MWZ (talk | contribs) (Created page with "This is a brief how-to for installing vnStar on Pi-Star, vnStat is a tool for collecting interface stats, it only knows about traffic through an interface, this means it will...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This is a brief how-to for installing vnStar on Pi-Star, vnStat is a tool for collecting interface stats, it only knows about traffic through an interface, this means it will not differentiate local lan traffic (like the dashboard) from internet traffic (like connecting to Brand Meister) for example.

1. Make sure your Pi-Star is already up to date:

 Go to this link to update: [1]
 Then upgrade to the current version (3.4.16 at the time of writing) using this link: [2]

2. Login to your PI-Star via SSH - you can either use PuTTY/Another SSH client - of the built in web SSH tool on Pi-Star.

 ╔═══════════════════════════════════════════════════════════════════════╗
 ║                                                                       ║
 ║           ██████╗ ██╗      ███████╗████████╗ █████╗ ██████╗           ║
 ║           ██╔══██╗██║      ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗          ║
 ║           ██████╔╝██║█████╗███████╗   ██║   ███████║██████╔╝          ║
 ║           ██╔═══╝ ██║╚════╝╚════██║   ██║   ██╔══██║██╔══██╗          ║
 ║           ██║     ██║      ███████║   ██║   ██║  ██║██║  ██║          ║
 ║           ╚═╝     ╚═╝      ╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝          ║
 ║                                                                       ║
 ╚═══════════════════════════════════════════════════════════════v3.4.16═╝
 From your Windows Computer:
 Pi-Star Dashboard:      http://pi-star/
 
 From your Apple iPhone, iPad, Macbook, iMac etc.
 Pi-Star Dashboard:      http://pi-star.local/
 
 Pi-Star's disk is read-only by default, enable read-write with "rpi-rw".
 Pi-Star built by Andy Taylor (MW0MWZ), pi-star tools all start "pistar-".
 
 [email protected](ro):~$

3. Make a folder for vnStat to store its database and put it on tmpfs so that it works with the read-only disk; To do this we need to edit the fstab and add the following line.

 [email protected](ro):~$ cat /etc/fstab 
 #File System		Mountpoint		Type	Options			Dump	Pass
 proc			/proc			proc	defaults		0
 /dev/mmcblk0p1		/boot			vfat	defaults,ro		2
 /dev/mmcblk0p2		/			ext4	defaults,noatime,ro	1
 # a swapfile is not a swap partition, no line here
 #   use  dphys-swapfile swap[on|off]  for that
 tmpfs			/run			tmpfs	nodev,noatime,nosuid,mode=1777,size=16m		0	0
 tmpfs			/var/tmp		tmpfs	nodev,noatime,nosuid,mode=1777,size=16m		0	0
 tmpfs			/tmp			tmpfs	nodev,noatime,nosuid,mode=1777,size=64m		0	0
 tmpfs			/var/log		tmpfs	nodev,noatime,nosuid,mode=0755,size=64m		0	0
 tmpfs			/var/lib/sudo		tmpfs	nodev,noatime,nosuid,mode=1777,size=16k		0	0
 tmpfs			/var/lib/dhcpcd5	tmpfs	nodev,noatime,nosuid,mode=1777,size=16k		0	0
 tmpfs			/var/lib/dhcp		tmpfs	nodev,noatime,nosuid,mode=1777,size=16k		0	0
 tmpfs			/var/lib/ntp		tmpfs	nodev,noatime,nosuid,mode=1777,size=16k		0	0
 tmpfs			/var/lib/vnstat		tmpfs	nodev,noatime,nosuid,mode=1777,size=4m		0	0
 tmpfs			/var/lib/logrotate	tmpfs	nodev,noatime,nosuid,mode=0755,size=16k		0	0
 tmpfs			/var/lib/nginx/body	tmpfs	nodev,noatime,nosuid,mode=1700,size=1m		0	0
 tmpfs			/var/lib/php5/sessions	tmpfs	nodev,noatime,nosuid,mode=0777,size=64k		0	0
 tmpfs			/var/lib/samba/private	tmpfs	nodev,noatime,nosuid,mode=0755,size=4m		0	0
 tmpfs			/var/cache/samba	tmpfs	nodev,noatime,nosuid,mode=0755,size=1m		0	0
 tmpfs			/var/spool/exim4/db	tmpfs	nodev,noatime,nosuid,mode=0750,size=64k		0	0
 tmpfs			/var/spool/exim4/input	tmpfs	nodev,noatime,nosuid,mode=0750,size=64k		0	0
 tmpfs			/var/spool/exim4/msglog	tmpfs	nodev,noatime,nosuid,mode=0750,size=64k		0	0

Without this step - the databases will not work correctly - you have been warned.

4. Create the folder and mount the new file system;

 [email protected](ro):~$ rpi-rw
 [email protected](rw):~$ sudo mkdir /var/lib/vnstat
 [email protected](rw):~$ sudo mount -a

5. Install vnStat

 [email protected](rw):~$ sudo apt-get install vnstat -y

6. Thats it - you can now wait for vnStat to collect some stats and then display them on the console; The below taken from my DMR system connected to BrandMeister, DMR+, NXDN, XLX and DAPNET all at once;

 [email protected](ro):~$ vnstat
 
                       rx      /      tx      /     total    /   estimated
  eth0: Not enough data available yet.
  wlan0:
        Jul '18     34.06 MiB  /    4.11 MiB  /   38.17 MiB  /   39.00 MiB
      yesterday     11.59 MiB  /    1.37 MiB  /   12.97 MiB
          today     22.47 MiB  /    2.73 MiB  /   25.20 MiB  /      37 MiB