Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    VLAN Email Reports

    Scheduled Pinned Locked Moved General pfSense Questions
    7 Posts 2 Posters 1.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      crucialguy
      last edited by

      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,

      1 Reply Last reply Reply Quote 0
      • NogBadTheBadN
        NogBadTheBad
        last edited by NogBadTheBad

        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

        Andy

        1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

        1 Reply Last reply Reply Quote 0
        • C
          crucialguy
          last edited by

          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...?

          1 Reply Last reply Reply Quote 0
          • NogBadTheBadN
            NogBadTheBad
            last edited by NogBadTheBad

            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 ...

            Andy

            1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

            1 Reply Last reply Reply Quote 1
            • C
              crucialguy
              last edited by

              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...?

              1 Reply Last reply Reply Quote 0
              • NogBadTheBadN
                NogBadTheBad
                last edited by NogBadTheBad

                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:

                Andy

                1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

                1 Reply Last reply Reply Quote 0
                • C
                  crucialguy
                  last edited by

                  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.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.