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

    Vnstat how-to

    Scheduled Pinned Locked Moved Traffic Monitoring
    29 Posts 13 Posters 13.1k 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
      Cino
      last edited by

      are you sure its missing php-gd? I think its because your missing libgd-2.1.0_7,1.txz.  I got it working right away with a manually install but I used the frontend interface from the previous package. You can get all the files minus the vnstat binary here: https://github.com/pfsense/pfsense-packages/tree/master/config/vnstat2

      To install vnstat binary, I needed the following packages install:

      http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/png-1.6.20.txz
      http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/jbigkit-2.1_1.txz
      http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/tiff-4.0.6_1.txz
      http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/jpeg-turbo-1.4.2.txz
      http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/freetype2-2.6.2.txz
      http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/fontconfig-2.11.1_1,1.txz
      http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/libgd-2.1.0_7,1.txz
      http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/vnstat-1.14.txz

      1 Reply Last reply Reply Quote 0
      • V
        vizi0n
        last edited by

        @virgiliomi:

        I think that also might explain the reason the developers got away from the RRD graphs and are using the new monitoring graph instead… because of all the dependencies associated with php-gd that they would need to maintain in the pfSense package repository. Which is also probably why vnstat isn't on their list to port.

        Doing a little digging... maybe this could work instead? It's javascript-based, served from php, with no mention of php-gd being needed... https://rakudave.ch/about_jsvnstat/

        This seems like a very promising interface, I will definately give it a try!

        @Cino:

        are you sure its missing php-gd? I think its because your missing libgd-2.1.0_7,1.txz.  I got it working right away with a manually install but I used the frontend interface from the previous package. You can get all the files minus the vnstat binary here: https://github.com/pfsense/pfsense-packages/tree/master/config/vnstat2

        To install vnstat binary, I needed the following packages install:

        http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/png-1.6.20.txz
        http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/jbigkit-2.1_1.txz
        http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/tiff-4.0.6_1.txz
        http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/jpeg-turbo-1.4.2.txz
        http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/freetype2-2.6.2.txz
        http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/fontconfig-2.11.1_1,1.txz
        http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/libgd-2.1.0_7,1.txz
        http://pkg.freebsd.org/freebsd:10:x86:64/release_3/All/vnstat-1.14.txz

        Interesting as well, I will check it out later on!

        1 Reply Last reply Reply Quote 0
        • jdillardJ
          jdillard
          last edited by

          @virgiliomi:

          I think that also might explain the reason the developers got away from the RRD graphs and are using the new monitoring graph instead… because of all the dependencies associated with php-gd that they would need to maintain in the pfSense package repository. Which is also probably why vnstat isn't on their list to port.

          I don't remember the exact dependancies, but yes that was a big reason. The new version of rrdtool (with graphing libraries) was going to double the size of the whole image.

          @virgiliomi:

          Doing a little digging… maybe this could work instead? It's javascript-based, served from php, with no mention of php-gd being needed... https://rakudave.ch/about_jsvnstat/

          Nice find, I'll have to take a look. With "a little work" I could probably do the same thing we did with RRD to the vnstat package (with a similar interface to that package) and get back bandwidth totals. If we could cut out the front-end dependencies that would be great (I wonder what their size/percentage of the total is). I have a lot to work on though so unfortunately this is low man on the totem pole for me right now.

          1 Reply Last reply Reply Quote 0
          • P
            pwnell
            last edited by

            I would also greatly appreciate getting this function to work again in 2.3.

            1 Reply Last reply Reply Quote 0
            • B
              bwdutton
              last edited by

              Here are the directions I used to manually install vnstat:

              ssh into router, cd to /root, download these:
              fetch http://pkg.freebsd.org/freebsd:10:x86:64/latest/All/vnstat-1.14.txz
              fetch http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz

              this will ask to install dependencies, say yes

              pkg install vnstat-1.14.txz

              this copies your existing vnstat data to a new home and leaves the existing files untouched

              mkdir -p /var/lib
              cp -rp /cf/conf/vnstat /var/lib
              chown -R vnstat:vnstat /var/lib/vnstat

              install the frontend

              cd /usr/local/www
              tar xvf /root/vnstat_php_frontend-1.5.1.tar.gz
              mv vnstat_php_frontend-1.5.1 vnstat

              configure front end, I use vi, use ed or whatever you prefer

              vi vnstat/config.php
              change $language to en: $language = 'en';
              change $iface list to your interfaces, e.g.:
              $iface_list = array('em0', 'em1', 'em2');
              add/edit the title lines for your interfaces, e.g.:
                  $iface_title['em0'] = 'LAN';
                  $iface_title['em1'] = 'WAN';
                  $iface_title['em2'] = 'JUMBOLAN';
              change $vnstat_bin = '/usr/local/bin/vnstat';

              fix image output:

              vi vnstat/graph_svg.php
              edit line 156:
              svg_text($iw / 2, ($ytm / 2), $text, array( 'stroke' => $cl['text'], 'fill' => $cl['text']['rgb'],'
              stroke-width' => 0, 'font-family' => SVG_FONT, 'font-weight' => 'bold', 'text-anchor' => 'middle' ));
              to:
              svg_text($iw / 2, ($ytm / 2), $text, array( 'stroke' => 'none', 'fill' => $cl['text']['rgb'],'
              stroke-width' => 0, 'font-family' => SVG_FONT, 'font-weight' => 'bold', 'text-anchor' => 'middle' ));

              run this once to make sure there are no errors

              /usr/local/bin/vnstat -u

              add the crontab entry to update the stats

              crontab -e
              */5 * * * * /usr/local/bin/vnstat -u

              And that should be it. Go to http://yourrouter/vnstat/ to view the results.

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

                vnstat is available for manual 'pkg install' now. That's a first step towards getting the full package back.

                Just SSH in, and run:

                pkg update 
                pkg install vnstat
                
                

                To install it.

                1 Reply Last reply Reply Quote 0
                • R
                  Retrograde
                  last edited by

                  @cmb:

                  vnstat is available for manual 'pkg install' now. That's a first step towards getting the full package back.

                  Just SSH in, and run:

                  pkg update 
                  pkg install vnstat
                  
                  

                  To install it.

                  Followed instructions, rebooted PFsense, see no package installed and no VNstat under status, any more instructions available/needed?

                  1 Reply Last reply Reply Quote 0
                  • jdillardJ
                    jdillard
                    last edited by

                    That just installs the FreeBSD package. It won't show up in the GUI, it's all CLI: http://humdi.net/vnstat/man/vnstat.html

                    1 Reply Last reply Reply Quote 0
                    • R
                      Retrograde
                      last edited by

                      Profound sadness, thanks for the update though!

                      1 Reply Last reply Reply Quote 0
                      • jdillardJ
                        jdillard
                        last edited by

                        I am working on a front-end for it. You can scroll through my post history if you want more info/screencasts.

                        1 Reply Last reply Reply Quote 0
                        • V
                          vizi0n
                          last edited by

                          My vnstatd is working perfectly on my 2.3.1 box. I have also added a rc.d script for startup/shutdown to try to prevent corrupt data files.

                          Location: /usr/local/etc/rc.d/vnstatd.sh

                          
                          #!/bin/sh
                          
                          . /etc/rc.subr
                          
                          name="vnstatd"
                          rcvar=vnstatd_enable
                          
                          load_rc_config $name
                          
                          : ${vnstatd_conf="/usr/local/etc/vnstat.conf"}
                          : ${vnstatd_flags="-d --config ${vnstatd_conf}"}
                          
                          required_files=${vnstatd_conf}
                          command="/usr/local/sbin/vnstatd"
                          
                          run_rc_command "$1"
                          
                          

                          Added this to my /etc/rc.conf.local

                          vnstatd_enable="YES"
                          

                          Now vnstatd starts at boot time and stops at shutdown.

                          I also added a backup script (that definately need tuning in order to only keep maybe a few days of backup in case something goes unnoticed). It was added to the crontab to run every hour

                          0 * * * * /root/vnstat_backup.sh >/dev/null 2>&1
                          

                          Here is the /root/vnstat_backup.sh. I'm not sure if I had to install bash, but I think I did :

                          #!/usr/local/bin/bash
                          
                          #START
                          TIME=`date +%Y-%m-%d_%H%M`		# This Command will add date in Backup File Name.
                          FILENAME=$TIME.tar.gz			# Here i define Backup file name format.
                          SRCDIR=/var/db/vnstat			# Location of Important Data Directory (Source of backup).
                          DESDIR=/root/vnstat_backup		# Destination of backup file.
                          #echo $TIME
                          tar -cpzf $DESDIR/$FILENAME $SRCDIR
                          #END
                          

                          This script creates a ton of files that need to be cleaned manually once in a while, so if someone could tune it to delete files older than X days it would be great! :)

                          1 Reply Last reply Reply Quote 1
                          • R
                            Retrograde
                            last edited by

                            Just curious if there's any update, Comcast is rolling out more data caps and Fios is still working on outfitting our building.

                            1 Reply Last reply Reply Quote 0
                            • johnpozJ
                              johnpoz LAYER 8 Global Moderator
                              last edited by

                              I just got an email from comcast about caps - its 1TB.. are you actually using more than 1TB a month?

                              An intelligent man is sometimes forced to be drunk to spend time with his fools
                              If you get confused: Listen to the Music Play
                              Please don't Chat/PM me for help, unless mod related
                              SG-4860 24.11 | Lab VMs 2.8, 24.11

                              1 Reply Last reply Reply Quote 0
                              • MikeV7896M
                                MikeV7896
                                last edited by

                                The Traffic Monitor package is in testing for pfSense 2.3.2 development builds now… just became available a day or two ago. A few minor bugs to be worked out and things that need to be tweaked so far, but it's there and it's working...

                                The S in IOT stands for Security

                                1 Reply Last reply Reply Quote 0
                                • johnpozJ
                                  johnpoz LAYER 8 Global Moderator
                                  last edited by

                                  This traffic monitor package is based on what?  Vnstat, Bandwidthd, something all new?  Curious - maybe I will jump to the 2.3.2 just to check it out..

                                  An intelligent man is sometimes forced to be drunk to spend time with his fools
                                  If you get confused: Listen to the Music Play
                                  Please don't Chat/PM me for help, unless mod related
                                  SG-4860 24.11 | Lab VMs 2.8, 24.11

                                  1 Reply Last reply Reply Quote 0
                                  • MikeV7896M
                                    MikeV7896
                                    last edited by

                                    @johnpoz:

                                    This traffic monitor package is based on what?  Vnstat, Bandwidthd, something all new?  Curious - maybe I will jump to the 2.3.2 just to check it out..

                                    It's based on vnstat, just using the same graphing engine as the monitoring graphs to visualize the data, getting it from vnstat's JSON output.

                                    The S in IOT stands for Security

                                    1 Reply Last reply Reply Quote 0
                                    • R
                                      Retrograde
                                      last edited by

                                      Just wondering if this is planned to be implemented into an upcoming version soon, the Comcast data caps just rolled out to a bunch of new states and like hell I trust their meter over my own: https://www.reddit.com/r/cordcutters/comments/5az24d/comcast_rolls_out_new_data_caps_in_28_states/

                                      1 Reply Last reply Reply Quote 0
                                      • MikeV7896M
                                        MikeV7896
                                        last edited by

                                        The Traffic Totals package is available in 2.3.x. Go to System > Package Manager > Status_Traffic_Totals. Install that package and you'll have a new item added to your Status menu for Traffic Totals. You'll need to enable it under the Advanced settings and after 5 minutes, it'll start showing data.

                                        The S in IOT stands for Security

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