VLAN Email Reports



  • Hi Guys,

    Quick question, it may not be possible...but thought it was worth asking.

    I get an email report sent to me for interface usage every day (WAN/WAN2 etc). This is using the vnstat package.

    Is there any way I can get it to report on VLAN interfaces? or is this simply only going to read physical interfaces?

    If so....does anyone have any alternative options in terms of how to get a decent email summary of individual VLAN interfaces?

    cheers,


  • Galactic Empire

    I run the following script from Email Reports:-

    #!/bin/csh
    foreach int ( igb0.2 igb0.3 igb0.4 igb0.5 igb0.6 igb0.7 enc0 pppoe0 )
    echo
    /usr/local/bin/vnstat -i $int -h
    echo
    end

    [2.4.3-RELEASE][admin@pfsense]/root/scripts: ls -alg
    total 28
    drwxr-xr-x 2 root wheel 512 Aug 13 13:57 .
    drwxr-xr-x 5 root wheel 512 Aug 2 18:17 ..
    -rwxr-xr-x 1 root wheel 124 Apr 15 19:56 interface-errors
    -rwxr-xr-x 1 root wheel 128 Apr 10 09:29 vnstat-daily
    -rwxr-xr-x 1 root wheel 166 Apr 10 09:30 vnstat-monthly
    -rwxr-xr-x 1 root wheel 128 Apr 10 09:29 vnstat-weekly
    -rwxr-xr-x 1 root wheel 166 Apr 10 09:30 vnstat-yearly
    [2.4.3-RELEASE][admin@pfsense]/root/scripts:

    0_1534171341003_Untitled.jpeg



  • Cheers - thanks for that, appreciate it. Knew it would be possible!

    Having a few issues getting these scripts to run though. Just keeps saying file not found.....

    I'm not massively experienced in Unix boxes, so I may be missing a pre-req...?


  • Galactic Empire

    Diagnostics -> Command Prompt -> Execute Shell Command mkdir /root/scripts/

    Diagnostics -> Command Prompt -> Execute Shell Command touch /root/scripts/vnstat-daily

    Diagnostics -> Command Prompt -> Execute Shell Command chmod 755 /root/scripts/vnstat-daily

    Diagnostics -> Edit File /root/scripts/vnstat-daily and load the file

    Add the following to the file and save:-

    #!/bin/csh
    foreach int ( igb0.2 igb0.3 igb0.4 igb0.5 igb0.6 igb0.7 enc0 pppoe0 )
    echo
    /usr/local/bin/vnstat -i $int -h
    echo
    end

    Diagnostics -> Command Prompt -> Execute Shell Command ls -alg /root/scripts/vnstat-daily

    -rwxr-xr-x 1 root wheel 128 Apr 10 09:29 vnstat-daily

    Or you could just run the following commands from the Email Reports page:-

    /usr/local/bin/vnstat -i igb0.2 -h
    /usr/local/bin/vnstat -i igb0.3 -h
    /usr/local/bin/vnstat -i igb0.4 -h

    etc ...



  • Nice one - that works...! Obviously I'll need to change the naming to each of my interfaces, but my vnstat database seems a bit confused (I've recently reset my VMWARE Nics, so they're not em0 rather than VMX. How can I get it to blank and rebuild the vnstat database...?


  • Galactic Empire

    Remove Status_Traffic_Totals and re install

    Otherwise I think you need to purge the database, I'd google it if I was you:-

    [2.4.3-RELEASE][admin@pfsense]/root: vnstat --longhelp
    vnStat 1.15 by Teemu Toivola <tst at iki dot fi>

    Query:
    -q, --query query database
    -h, --hours show hours
    -d, --days show days
    -m, --months show months
    -w, --weeks show weeks
    -t, --top10 show top 10 days
    -s, --short use short output
    -ru, --rateunit swap configured rate unit
    --oneline show simple parseable format
    --exportdb dump database in text format
    --importdb import previously exported database
    --json show database in json format
    --xml show database in xml format
    Modify:
    --create create database
    --delete delete database
    -u, --update update database
    -r, --reset reset interface counters
    --sync sync interface counters
    --enable enable interface
    --disable disable interface
    --nick set a nickname for interface
    --cleartop clear the top 10
    --rebuildtotal rebuild total transfers from months
    Misc:
    -i, --iface select interface (default: eth0)
    -?, --help short help
    -D, --debug show some additional debug information
    -v, --version show version
    -tr, --traffic calculate traffic
    -l, --live show transfer rate in real time
    --style select output style (0-4)
    --iflist show list of available interfaces
    --dbdir select database directory
    --locale set locale
    --config select config file
    --savemerged save merged database to current directory
    --showconfig dump config file with current settings
    --testkernel check if the kernel is broken
    --longhelp display this help

    See also "man vnstat".
    [2.4.3-RELEASE][admin@pfsense]/root:



  • Yeah, I had to purge the database in the end. All good now, and that script works like a charm. Thanks again for your help! Appreciated.