Vnstat how-to
-
And if that doesn't happen, I think the pfSense developers will get to migrating some of these other packages, including vnstat… but it's not going to be as quick as it would if someone else were to take it on.
Also, it could be more than just Bootstrap conversion. The web server for the pfSense GUI was also changed, so there may be stuff that needs to be fixed in the change from lighttpd to nginx.
There are many that have asked about having vnstat converted (along with other packages not in the initial group)... so I'm sure it will eventually happen... it's just a question of when.
As to a "quick" installation... the vnstat pfSense package is actually a couple of different things... the first is the vnstat utility, which sits and watches the interfaces... the second is the php web interface, which produces all the pretty graphs from the data that vnstat collects. I know vnstat itself is a package that could be installed from the FreeBSD repository... though there's a chance that it could break something in pfSense as a result of it not being from the pfSense repository. But I don't know if the php interface is something that has an easily installed package or not.
-
I have finally gotten vnstat manually installed - now I just have to work on the php interface
Myk
-
PM me if you need any advice on the UI conversion. The pinned notes on this page should help.
-
So apparently the only package not yet on their list that likely will be converted to 2.3 is NUT. Not looking good for vnstat unless someone steps up to do the conversion.
If I had the time and knowledge, I'd probably take a stab at it… but I don't have either. Happy to help test and give feedback... just not one for coding.
-
@virgiliomi:
So apparently the only package not yet on their list that likely will be converted to 2.3 is NUT. Not looking good for vnstat unless someone steps up to do the conversion.
If I had the time and knowledge, I'd probably take a stab at it… but I don't have either. Happy to help test and give feedback... just not one for coding.
If someone knows of a developer who has the ability to do this, I would be happy to spearhead a crowdsource campaign to commission the conversion.
-
I managed to install vnstat 1.14 from the FreeBSD repo. Then downloaded the vnstat php interface from http://www.sqweek.com/sqweek/index.php?p=1 and added it manually to /usr/local/www/vnstat
Now the only thing that doesn't work is the graphic on the php interface. Seems like it is missing php-gd to generate the graphics, I think.
Here's the error from the img call of the graph.php page:
Fatal error: Call to undefined function imagecreatetruecolor() in /usr/local/www/vnstat/graph.php on line 61 Call Stack: 0.0002 120032 1\. {main}() /usr/local/www/vnstat/graph.php:0 0.0165 181428 2\. output_image() /usr/local/www/vnstat/graph.php:302 0.0165 181540 3\. init_image() /usr/local/www/vnstat/graph.php:282
At least I have my numbers! Just not as pretty as I wished it was :)
-
Is there not a package in the FreeBSD repository to install php-gd? Or is it a different version of PHP than what pfSense has/uses?
-
When I manually installed it - it wanted a couple of libraries, font package - 4 or 5 dependencies if I remember correctly
Myk
-
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/
-
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 -
@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! :)