FreeBSD - vnstat

zuletzt getestet 16.09.2019 (www)

vnstat

portmaster net/vnstat

ordner für db erstellen

mkdir /var/lib/vnstat
chown -R vnstat:vnstat /var/lib/vnstat

/etc/rc.conf

# sysrc vnstat_enable="YES"

/usr/local/etc/vnstat.conf

# vnStat 1.15 config file
##

# default interface
Interface "vtnet0"

# location of the database directory
DatabaseDir "/var/lib/vnstat"

# locale (LC_ALL) ("-" = use system locale)
Locale "-"

# on which day should months change
MonthRotate 1

# date output formats for -d, -m, -t and -w
# see 'man date' for control codes
DayFormat    "%x"
MonthFormat  "%b '%y"
TopFormat    "%x"

# characters used for visuals
RXCharacter       "%"
TXCharacter       ":"
RXHourCharacter   "r"
TXHourCharacter   "t"

# how units are prefixed when traffic is shown
# 0 = IEC standard prefixes (KiB/MiB/GiB/TiB)
# 1 = old style binary prefixes (KB/MB/GB/TB)
UnitMode 0

# output style
# 0 = minimal & narrow, 1 = bar column visible
# 2 = same as 1 except rate in summary and weekly
# 3 = rate column visible
OutputStyle 3

# used rate unit (0 = bytes, 1 = bits)
RateUnit 1

# try to detect interface maximum bandwidth, 0 = disable feature
# MaxBandwidth will be used as fallback value when enabled
BandwidthDetection 1

# maximum bandwidth (Mbit) for all interfaces, 0 = disable feature
# (unless interface specific limit is given)
MaxBandwidth 1000

# interface specific limits
#  example 8Mbit limit for 'ethnone':
MaxBWethnone 8

# how many seconds should sampling for -tr take by default
Sampletime 5

# default query mode
# 0 = normal, 1 = days, 2 = months, 3 = top10
# 4 = exportdb, 5 = short, 6 = weeks, 7 = hours
QueryMode 0

# filesystem disk space check (1 = enabled, 0 = disabled)
CheckDiskSpace 1

# database file locking (1 = enabled, 0 = disabled)
UseFileLocking 1

# how much the boot time can variate between updates (seconds)
BootVariation 15

# log days without traffic to daily list (1 = enabled, 0 = disabled)
TrafficlessDays 1

# vnstatd
##

# switch to given user when started as root (leave empty to disable)
DaemonUser ""

# switch to given user when started as root (leave empty to disable)
DaemonGroup ""

# how often (in seconds) interface data is updated
UpdateInterval 30

# how often (in seconds) interface status changes are checked
PollInterval 5

# how often (in minutes) data is saved to file
SaveInterval 5

# how often (in minutes) data is saved when all interface are offline
OfflineSaveInterval 30

# how often (in minutes) bandwidth detection is redone when
# BandwidthDetection is enabled (0 = disabled)
BandwidthDetectionInterval 5

# force data save when interface status changes (1 = enabled, 0 = disabled)
SaveOnStatusChange 1

# enable / disable logging (0 = disabled, 1 = logfile, 2 = syslog)
UseLogging 2

# create dirs if needed (1 = enabled, 0 = disabled)
CreateDirs 1

# update ownership of files if needed (1 = enabled, 0 = disabled)
UpdateFileOwner 1

# file used for logging if UseLogging is set to 1
LogFile "/var/log/vnstat/vnstat.log"

# file used as daemon pid / lock file
PidFile "/var/run/vnstat/vnstat.pid"

# vnstati
##

# title timestamp format
HeaderFormat "%x %H:%M"

# show hours with rate (1 = enabled, 0 = disabled)
HourlyRate 1

# show rate in summary (1 = enabled, 0 = disabled)
SummaryRate 1

# layout of summary (1 = with monthly, 0 = without monthly)
SummaryLayout 1

# transparent background (1 = enabled, 0 = disabled)
TransparentBg 0

# image colors
CBackground     "FFFFFF"
CEdge           "AEAEAE"
CHeader         "606060"
CHeaderTitle    "FFFFFF"
CHeaderDate     "FFFFFF"
CText           "000000"
CLine           "B0B0B0"
CLineL          "-"
CRx             "92CF00"
CTx             "606060"
CRxD            "-"
CTxD            "-"

start

# service vnstat start
Starting vnstat.
No interfaces found in database, adding available interfaces...
Interface "vtnet0" added with 1000 Mbit bandwidth limit.
Interface "pflog0" added with 1000 Mbit bandwidth limit.
-> 2 new interfaces found.
Limits can be modified using the configuration file. See "man vnstat.conf".
Unwanted interfaces can be removed from monitoring with "vnstat --remove".

# vnstat

                  rx      /      tx      /     total    /   estimated
pflog0:
   2019-11           0 B  /       336 B  /       336 B  /     --     
     today           0 B  /       336 B  /       336 B  /     --     

vtnet0:
   2019-11    497.71 KiB  /    2.06 MiB  /    2.55 MiB  /    7.42 MiB
     today    497.71 KiB  /    2.06 MiB  /    2.55 MiB  /    3.66 MiB

 # vnstat --remove --force -i pflog0
Interface "pflog0" removed from database.
The interface will no longer be monitored. Use --add
if monitoring the interface is again needed.

# vnstat
Database updated: 2019-11-08 16:43:00

vtnet0 since 2019-11-08

      rx:  497.71 KiB      tx:  2.06 MiB      total:  2.55 MiB

monthly
                 rx      |     tx      |    total    |   avg. rate
 ------------------------+-------------+-------------+---------------
   2019-11    497.71 KiB |    2.06 MiB |    2.55 MiB |       32 bit/s
 ------------------------+-------------+-------------+---------------
 estimated       --      |    7.42 MiB |    7.42 MiB |

daily
                 rx      |     tx      |    total    |   avg. rate
 ------------------------+-------------+-------------+---------------
     today    497.71 KiB |    2.06 MiB |    2.55 MiB |      355 bit/s
 ------------------------+-------------+-------------+---------------
 estimated       714 KiB |    2.96 MiB |    3.66 MiB |

mutt

portmaster mail/mutt

===>>> The following actions will be taken if you choose to proceed:
Install mail/mutt
Install misc/mime-support
Install security/cyrus-sasl2
Install textproc/docbook-xsl
Install textproc/docbook
Install textproc/docbook-sgml
Install textproc/iso8879
Install textproc/xmlcatmgr
Install textproc/docbook-xml
Install textproc/xmlcharent
Install textproc/sdocbook-xml
Install textproc/libxslt
Install security/libgcrypt
Install security/libgpg-error
Install www/lynx

das dauert eine ganze weile.... :)

/etc/crontab

0       0       *       *       *       root    /usr/local/bin/vnstati -h -i vtnet0 -o /tmp/stunde.png && /usr/local/bin/vnstati -d -i vtnet0 -o /tmp/tag.png && /usr/local/bin/vnstati -m -i vtnet0 -o /tmp/monat.png && echo "" | /usr/local/bin/mutt -s "(voodoo) vnstat" root -a /tmp/monat.png /tmp/tag.png /tmp/stunde.png