macos - vnstat
Page content
vnstat
wanna install vnstat on your mac ?
install
brew install vnstat gsed
and you’ll get the following Message after installation:
==> vnstat
To monitor interfaces other than "en0" edit /opt/homebrew/etc/vnstat.conf
To start vnstat now and restart at startup:
sudo brew services start vnstat
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/vnstat/bin/vnstatd --nodaemon --config /opt/homebrew/etc/vnstat.conf
Service Location
Let’s build a directory for the Database
mkdir ~/Library/vnstat
Path
Depending where you’re config files got installed …
file="/usr/local/etc/vnstat.conf"
or
file="/opt/homebrew/etc/vnstat.conf"
Config File - sed
Let’s update the Config File:
gsed -i 's/;Interface .*/Interface "en0"/' $file
gsed -i 's/;DatabaseDir.*/DatabaseDir "\/Users\/stoege\/Library\/vnstat"/' $file
Config File - manual
or do it manual …
echo $file
# vnStat 2.11 configuration file
#
# lines starting with # or ; are comments, everything has default
# values, remove ; before each option to change its value
# default interface (leave empty for automatic selection)
Interface "en0"
# location of the database directory
DatabaseDir "/Users/stoege/Library/vnstat"
...
Start or Restart Service
brew services restart vnstat
get Stats
user@box % vnstat -h
en0 / hourly
hour rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
2023-12-04
12:00 80.87 MiB | 113.74 MiB | 194.61 MiB | 3.91 Mbit/s
------------------------+-------------+-------------+---------------
Any Comments ?
sha256: db0efe023c23fee54d0a17a9d0e115a07939482894021f5244f72e21cffd1e3d