Well, I've decided to scrap the vnstat method afterall, because it would require people to have that installed to make use of the command. So I'm looking at using the openvpn status file to get some stats from instead.
But I'm seeing some strange results... I wanted to make sure my logic is right on this... because, I'm seeing varying results based on the amount of KB or MB coming off from the main page's internet traffic status, and the amount of data my internal Google Wifi router is constantly pushing and pulling based on its own stats.
So here's a snapshot of traffic 1 min apart from each other.
Code:
OpenVPN STATISTICS
Updated,2022-03-20 11:19:56
TUN/TAP read bytes,116112618
TUN/TAP write bytes,180382783
TCP/UDP read bytes,185799812
TCP/UDP write bytes,120711840
Auth read bytes,180382835
pre-compress bytes,0
post-compress bytes,0
pre-decompress bytes,0
post-decompress bytes,0
(after 60 seconds)
OpenVPN STATISTICS
Updated,2022-03-20 11:20:56
TUN/TAP read bytes,118762713
TUN/TAP write bytes,183205992
TCP/UDP read bytes,188713696
TCP/UDP write bytes,123466010
Auth read bytes,183206044
pre-compress bytes,0
post-compress bytes,0
pre-decompress bytes,0
post-decompress bytes,0
My question is, should I only be calculating based off the TUN/TAP stats, or should I be adding the TCP/UDP results into this as well? Do the Auth bytes come into play into calculating this? I haven't found any conclusive documentation on how to calculate an avg bandwidth from these results, but this is my math. Could you please comment if I'm on the right track?
Current TUN/TAP Read Bytes: 118762713 Bytes
60s old TUN/TAP Read Bytes: 116112618 Bytes
Current TUN/TAP Write Bytes: 183205992 Bytes
60s old TUN/TAP Write Bytes: 180382783 Bytes
Difference in Read Bytes over 60 seconds: 2650095 Bytes
Difference in Write Bytes over 60 seconds: 2823209 Bytes
Calculate Read Mb: 2650095 / 125000 = 21.20076 Mb
Calculate Write Mb: 2823209 / 125000 = 22.585672 Mb
Calculate Read Mbps: 21.20076 / 60 = 0.353346 Mbps
Calculate Write Mbps: 22.585672 / 60 = 0.376427 Mbps
The reason why I'm questioning these results is because 95% of my internal traffic should be going over VPN. These figures of 0.3Mbps is not realistic. As mentioned, my Google Wifi mesh network runs completely across the VPN tunnel, and it's constantly pushing 3-5Mbps (thanks to a bunch of Google Nest Cams):
And the main router status constantly shows about an average of 300-600KBps being sent, which is about 3-5Mbps:
These stats are more in range based on what I'm expecting traffic being sent from my Google Wifi Mesh, compared to what I'm calculating based off raw figure for the tunnel alone from the OpenVPN status file.
Am I going about this the right way?