Vnstat how-to
-
@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!
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.txzInteresting as well, I will check it out later on!
-
@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.
-
I would also greatly appreciate getting this function to work again in 2.3.
-
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.gzthis 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/vnstatinstall the frontend
cd /usr/local/www
tar xvf /root/vnstat_php_frontend-1.5.1.tar.gz
mv vnstat_php_frontend-1.5.1 vnstatconfigure 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 -uAnd that should be it. Go to http://yourrouter/vnstat/ to view the results.
-
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.
-
@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?
-
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
-
Profound sadness, thanks for the update though!
-
I am working on a front-end for it. You can scroll through my post history if you want more info/screencasts.
-
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! :)
-
Just curious if there's any update, Comcast is rolling out more data caps and Fios is still working on outfitting our building.
-
I just got an email from comcast about caps - its 1TB.. are you actually using more than 1TB a month?
-
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...
-
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..
-
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.
-
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/
-
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.