OpenVZ Forum


Home » General » HowTo » Bandwidth Accounting + Graphing and More for OpenVZ
Bandwidth Accounting + Graphing and More for OpenVZ [message #1341] Tue, 07 February 2006 02:56 Go to next message
phpfreak is currently offline  phpfreak
Messages: 47
Registered: January 2006
Member
From: *tampfl.dsl-w.verizon.net
Well, I found the iptables method of collecting bandwidth a bit too hands on and unforgiving. Therefore, using my mad php skills, and some bash scripting, I've whipped up an set of applications that allows you a more graphical and accurate overview using rrdtool, and some PHP scripts. You can have full bandwidth accounting for your VPS including daily, monthly and weekly tabulated data in about 5 minutes of setup time.

Here's some screen shots (full size screens are on our site):

http://www.serverpowered.com/images/bw1_thumb.jpg

http://www.serverpowered.com/images/bw2_thumb.jpg

http://www.serverpowered.com/images/bw3_thumb.jpg

The total process takes about 5 minutes to setup using the pre-created CentOS 4.2 templates that I have packaged up for you, and installing a bash script that does the collection.

The cool thing is, when you add a new VPS, the cronjob will automatically detect this and add the graphs for you. In addition, when you delete a VPS, the graphs and .rrd files will be deleted with it.

The only thing you need to install on the hostnode is the bash script and the rrdtool rpm ( or compile rrdtool from source ). The rest of the display, and web server that displays these graphs is located inside the VE that you'll create specifically for this purpose.

I just wanted to give something back to the community. Thanks for all that you are doing to help this awesome solution grow and become even more evolved Smile

The full details are found at ServerPowered.com, our server website: http://www.serverpowered.com/openvz-bandwidth-accounting.php

Please direct any discussions here, and not on our server company's website Smile I'll subscribe to this and help you out if you need it.


Enjoy!




[Updated on: Tue, 07 February 2006 03:14]

Report message to a moderator

Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #1345 is a reply to message #1341] Tue, 07 February 2006 04:44 Go to previous messageGo to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
From: *valornet.com
This part isn't working, no link to the file.

Download: openvz-bandwidth-1.0.tar.gz

Shows link to http://www.serverpowered.com/

And thanks for the setup of this, been wondering an easier way for tracking.

Scooter


Scooter Harris
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #1346 is a reply to message #1345] Tue, 07 February 2006 04:46 Go to previous messageGo to next message
phpfreak is currently offline  phpfreak
Messages: 47
Registered: January 2006
Member
From: *tampfl.dsl-w.verizon.net
I have corrected the link on the guide.

Thanks,




Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #1347 is a reply to message #1341] Tue, 07 February 2006 04:55 Go to previous messageGo to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
From: *valornet.com
Thanks buddy.


Scooter Harris
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #1348 is a reply to message #1347] Tue, 07 February 2006 04:57 Go to previous messageGo to next message
phpfreak is currently offline  phpfreak
Messages: 47
Registered: January 2006
Member
From: *tampfl.dsl-w.verizon.net
Not a problem. Wish I could get Hybodus to do this for us, but that would be a pain!



Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #1349 is a reply to message #1341] Tue, 07 February 2006 05:07 Go to previous messageGo to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
From: *valornet.com
Smile ya hybodus is nice.

I keep getting this, and yes i edited the script.

VPS is not running
VPS config file does not exist



Scooter Harris
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #1350 is a reply to message #1349] Tue, 07 February 2006 05:08 Go to previous messageGo to next message
phpfreak is currently offline  phpfreak
Messages: 47
Registered: January 2006
Member
From: *tampfl.dsl-w.verizon.net
That's fine. It just meanst that there's a VE that's not running inside your /vz/root directory. You probably created one and stopped it. It's safe to ignore that message.



Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #1351 is a reply to message #1341] Tue, 07 February 2006 05:10 Go to previous messageGo to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
From: *valornet.com
Alright, gotcha Smile

keep up the good work


Scooter Harris
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #1362 is a reply to message #1341] Tue, 07 February 2006 11:32 Go to previous messageGo to next message
devnu11 is currently offline  devnu11
Messages: 64
Registered: September 2005
Location: USA
Member

From: *logical.net
Hats off to phpfreak Very Happy I had the setup done about ten minutes after you made the post. I worked around the little link snafu and found the file without problems. I did add >/dev/null 2>&1 to the cron job as it kept it quiet due to a couple of stopped VPS. You Sir! Are a gentleman and a scholar. Thank you for this contribution, I appreciate it very much.

Greg



Just Because You Have One, Doesn't Mean You Have To Be One!
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #2121 is a reply to message #1341] Tue, 21 March 2006 03:06 Go to previous messageGo to next message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
From: *conceptualarc.com
http://vzdrop.serverpowered.net/centos-4-i386-bandwidth.tar. gz is 404 File Not Found.

Anywhere else I can get that file?
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #2123 is a reply to message #2121] Tue, 21 March 2006 03:36 Go to previous messageGo to next message
jbond007 is currently offline  jbond007
Messages: 78
Registered: January 2006
Location: Miami
Member
From: *sip.mia.bellsouth.net
1 make sure the gataway is ok !

2 make sure you not change the default setting the vps bandwidt name will be 69
or check the files
cat /root/bin/bandwidth.sh

look the line
BWVE=69
BWDIR=home/bandwidth
make sure the vps will be name 69

and recreate the vps name openvz-bandwidth-1.0.tar.tar

Done !
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #2696 is a reply to message #1341] Mon, 17 April 2006 11:17 Go to previous messageGo to next message
miroslawgon is currently offline  miroslawgon
Messages: 16
Registered: April 2006
Junior Member
From: 69.216.119*
The link to the centos-4-i386-bandwidth.tar.gz doesn't work Crying or Very Sad

The requested URL /centos-4-i386-bandwidth.tar.gz was not found on this server.
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #2805 is a reply to message #1341] Fri, 21 April 2006 12:09 Go to previous messageGo to next message
asmith is currently offline  asmith
Messages: 3
Registered: April 2006
Junior Member
From: 193.112.229*
Yea, it's down still Sad

Anyone have a copy of this they could ftp me? I'll be happy to keep it somewhere till the proper link is fixed.
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #2809 is a reply to message #1341] Fri, 21 April 2006 16:04 Go to previous messageGo to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
From: *valornet.com
http://scripts.maximumvps.com/centos-4-i386-bandwidth.tar.gz

You can grab it from there.


Scooter Harris
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #2810 is a reply to message #2809] Fri, 21 April 2006 16:55 Go to previous messageGo to next message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
From: *conceptualarc.com
Thanks, Scooter.
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #2811 is a reply to message #1341] Fri, 21 April 2006 16:56 Go to previous messageGo to next message
asmith is currently offline  asmith
Messages: 3
Registered: April 2006
Junior Member
From: *bulldogdsl.com
Thanks alot, greatly apprecated.

[Edit]
Can also be found at http://wired-network.com/centos-4-i386-bandwidth.tar.gz as well now

[Updated on: Fri, 21 April 2006 17:03]

Report message to a moderator

Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #3030 is a reply to message #1341] Tue, 09 May 2006 11:40 Go to previous messageGo to next message
miroslawgon is currently offline  miroslawgon
Messages: 16
Registered: April 2006
Junior Member
From: 69.216.109*
I have problem,

When I want to view a vps bandwith I get

Notice: Undefined offset: 1 in /var/www/html/bandwidth.php on line 368
Notice: Undefined index: 2006 in /var/www/html/bandwidth.php on line 421

index.php?t=getfile&id=141&private=0

also the main page with all vps charts looks like there are images missing.

Waited 5 day and nothing, the rrd files in the bandwith vps are changing, but still no charts.

I did everything step by step

Do I need to change or add some rpm packages on host machine? (I have rrdtool installed)
  • Attachment: vps.jpg
    (Size: 55.40KB, Downloaded 10936 times)
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #3049 is a reply to message #3030] Tue, 09 May 2006 18:52 Go to previous messageGo to next message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
From: *conceptualarc.com
I am also having this exact problem.
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #3496 is a reply to message #1341] Wed, 31 May 2006 10:45 Go to previous messageGo to next message
miroslawgon is currently offline  miroslawgon
Messages: 16
Registered: April 2006
Junior Member
From: *dsl.sfldmi.ameritech.net
I solved the problem of missing charts. Smile

rrdtool version must be 1.0.49 in order to see the charts.
higher version won't work.

error with version higher then 1.0.49:
--------------------------------------
Notice: Undefined offset: 1 in /var/www/html/bandwidth.php on line 368
Notice: Undefined index: 2006 in /var/www/html/bandwidth.php on line 421
--------------------------------------

Link to rpm package for rhel4/centos4 users
http://ftp.opennms.org/pub/dependencies/rrdtool/rhel4/
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #6943 is a reply to message #1341] Thu, 28 September 2006 09:43 Go to previous messageGo to next message
Foblas is currently offline  Foblas
Messages: 16
Registered: August 2006
Location: Belarus, Minsk
Junior Member

From: 212.98.173*
There is no working link for centos-4-i386-bandwidth.tar.gz
Can anybodu update links?
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #21333 is a reply to message #1341] Fri, 05 October 2007 10:22 Go to previous messageGo to next message
null is currently offline  null
Messages: 15
Registered: August 2007
Junior Member
From: 85.185.70*
hi
any one can sand this to me!?
all links are broken!!
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #25580 is a reply to message #1341] Wed, 02 January 2008 06:15 Go to previous messageGo to next message
Shanlar is currently offline  Shanlar
Messages: 2
Registered: January 2008
Junior Member
From: *dsl.scrm01.sbcglobal.net
is this project dead? all of the centos-image links are broken and apparently the tar that contains the bandwidth script doesn't contain the needed web files, so the centos-image is a must have.

if somebody could put up a working link for the centos-image it would be greatly appreciated!
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #25596 is a reply to message #1341] Wed, 02 January 2008 17:52 Go to previous messageGo to next message
miroslawgon is currently offline  miroslawgon
Messages: 16
Registered: April 2006
Junior Member
From: *dsl.sfldmi.sbcglobal.net
Here is the centos-4-i386-bandwidth.tar.gz, I don't know how long the link will be available so grab it while you can.

http://www.megaupload.com/?d=967KJIH6

TIP: If you don't want to collect bandwidth usage of certain VPS add this line at the end of bandwidth.sh script. Physical interfaces attached to VPS won't have any bandwidth graphs.

rm -f /vz/private/<bandwidth-vps number>/home/bandwidth/vps-<number>.rrd
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #25619 is a reply to message #25580] Thu, 03 January 2008 16:20 Go to previous messageGo to next message
miroslawgon is currently offline  miroslawgon
Messages: 16
Registered: April 2006
Junior Member
From: *dsl.sfldmi.sbcglobal.net
Try this one:

http://www.megaupload.com/?d=CXUAR0H6

Its updated to CentOS 4.6 and rrdtool 1.2.23

1. Update rrdtool on your hardware node to 1.2.23 (can be found at rpmforge)
2. Remove all the .rrd files form bandwidth vps /home/bandwidth/
3. Execute bandwidth.sh on hardware node, new .rrd files should be created in bandwidth vps /home/bandwidth/
4. Open a web browser an type IP address of your bandwidth vps

Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #25654 is a reply to message #1341] Sun, 06 January 2008 03:12 Go to previous messageGo to next message
XaoZoov is currently offline  XaoZoov
Messages: 4
Registered: November 2007
Junior Member
From: *dhcp.insightbb.com
Anyone have an idea why I'm getting a failed dependency? I checked, I have the libraries, and if I do a force install with --nodeps I never get any graphs generated.

[root@tiers bandwidth_accounting]# rpm -ivh rrdtool-1.0.49-3.x86_64.rpm
warning: rrdtool-1.0.49-3.x86_64.rpm: V3 DSA signature: NOKEY, key ID 9c800aca
error: Failed dependencies:
libpng.so.3()(64bit) is needed by rrdtool-1.0.49-3.x86_64
[root@tiers bandwidth_accounting]# rpm -q libpng
libpng-1.2.7-3.el4_5.1
libpng-1.2.7-3.el4_5.1
[root@tiers bandwidth_accounting]# find /usr -name libpng.so.3
/usr/lib64/libpng.so.3
/usr/lib/libpng.so.3
[root@tiers bandwidth_accounting]# cd /usr/lib
[root@tiers lib]# ls -l libpng*
lrwxrwxrwx 1 root root 19 Jan 5 01:53 libpng12.so.0 -> libpng12.so.0.1.2.7
-rwxr-xr-x 1 root root 142808 Oct 24 04:48 libpng12.so.0.1.2.7
lrwxrwxrwx 1 root root 17 Jan 5 01:53 libpng.so.3 -> libpng.so.3.1.2.7
lrwxrwxrwx 1 root root 19 Jan 5 01:53 libpng.so.3.1.2.7 -> libpng12.so.0.1.2.7
[root@tiers lib]# ls -l ../lib64/libpng*
lrwxrwxrwx 1 root root 19 Jan 5 01:53 ../lib64/libpng12.so.0 -> libpng12.so.0.1.2.7
-rwxr-xr-x 1 root root 163432 Oct 24 04:50 ../lib64/libpng12.so.0.1.2.7
lrwxrwxrwx 1 root root 17 Jan 5 01:53 ../lib64/libpng.so.3 -> libpng.so.3.1.2.7
lrwxrwxrwx 1 root root 19 Jan 5 01:53 ../lib64/libpng.so.3.1.2.7 -> libpng12.so.0.1.2.7
[root@tiers lib]#

Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #25657 is a reply to message #1341] Sun, 06 January 2008 06:34 Go to previous messageGo to next message
XaoZoov is currently offline  XaoZoov
Messages: 4
Registered: November 2007
Junior Member
From: *dhcp.insightbb.com
Ok, I was having trouble getting rrd to generate traffic and the version downloaded from here to work.

I'm on CentOS v4.5 64bit. So what I did as opposed to using the bandwidth VPS that I downloaded from here, is I used the centos-4-x86_64-minimal.tar.gz template and then installed php and the rrdtool from Dag's repository on both the master node and the new VPS. I also created the /home/bandwidth directory with 777 permissions and copied the files from the bandwidth VPS /var/www/html directory into my new minimal installation.

Everything worked like a champ from there.

After I get the rest of my servers and services built, I'll right an updated installation document that doesn't require the download of the VPS along with proper credits.

Hopefully though, the quick instructions up top with get some of you up and running.

Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #25763 is a reply to message #25657] Tue, 08 January 2008 17:53 Go to previous messageGo to next message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
From: 208.20.197*
Yes, please do. I'd love to have a proper installation process document to follow. Plus I'd rather do it in Debian, so I'd adapt the instructions for my situation.

Thanks!
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #37737 is a reply to message #1341] Thu, 15 October 2009 09:33 Go to previous messageGo to next message
dvazart is currently offline  dvazart
Messages: 37
Registered: October 2008
Location: France
Member
From: *w80-13.abo.wanadoo.fr
Hi !!

I just update this excellent script for Debian Lenny x64 on both (HN and CT) and with the 1.3.1 version of rrdtool, I also did some minor changes in the script.

Here is a little HOWTO implement it :


1.
You must have installed Debian Lenny x64 + OpenVZ + rrdtool on your HN.
apt-get install rrdtool


2. Download and create a container using this template:
wget http://www.vazart.net/openvz/Debian-Lenny-x64_bandwidth.tar.gz

mv Debian-Lenny-x64_bandwidth.tar.gz  /vz/template/cache/

vzctl create 101 --ostemplate debian-5.0-x86_64  --config  ve-vps.basic --hostname graphs.yourdomain.com --ipadd xxx.xxx.xxx.xxx --name graphs
vzctl set 101 --onboot yes --nameserver xxx.xxx.xxx.xxx --userpasswd root:xxxxxxx --save
vzctl start 101

You can errase my old rrd data:
vzctl exec 101 rm /home/bandwidth/*


3. Download the script (Bash) to collecting data:
wget http://www.vazart.net/openvz/bandwidth.sh

You can open it and change the container number in the BWVE variable.

4. You can make an crontab to run this script every 5 min:
crontab -e

*/5 * * * *     root /root/bandwidth.sh 1>/var/log/vz-bandwidth.log 2>&1


5. Wait 5 min then visit: http://xxx.xxx.xxx.xxx/ and happy graphing !

I hope it's useful!



----------- Daniel Vazart ------------
"Knowledge is power, Sharing is human"
------- http://www.vazart.net --------
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #39813 is a reply to message #1341] Fri, 04 June 2010 16:10 Go to previous messageGo to next message
kwadrofonik is currently offline  kwadrofonik
Messages: 3
Registered: May 2010
Junior Member
From: *pppoe-dynamic.nb.aliant.net
Thanks for your hard work! Can you please post the template internals so I can apply it to an existing VE (and save you 193M of bandwidth)
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #43070 is a reply to message #1341] Thu, 14 July 2011 15:17 Go to previous messageGo to next message
nylonzoo is currently offline  nylonzoo
Messages: 1
Registered: July 2011
Junior Member
From: *hsd1.in.comcast.net
Thanks for this download. I think it works pretty good. I have really been in need of something like this, so I greatly appreciate it. Thanks a lot.

Peace
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #44766 is a reply to message #1341] Fri, 30 December 2011 21:31 Go to previous messageGo to next message
amoon is currently offline  amoon
Messages: 2
Registered: September 2011
Location: B.C, Canada
Junior Member

From: *vf.shawcable.net
This doesn't appear to be working on the RHEL6 branch, any thoughts?
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #50161 is a reply to message #2811] Tue, 30 July 2013 23:24 Go to previous messageGo to next message
jorgea is currently offline  jorgea
Messages: 2
Registered: May 2012
Location: burbank ca
Junior Member
From: *public.wayport.net
Thanks for the det
Re: Bandwidth Accounting + Graphing and More for OpenVZ [message #51098 is a reply to message #50161] Mon, 03 February 2014 20:57 Go to previous message
gral is currently offline  gral
Messages: 26
Registered: May 2006
Junior Member

From: *cab.prima.net.ar

Hello I have problems with the above script although I could made the rrd files sucesfully the script didnt made the graphs with them.

Should i create the graphs manually ?

Thanks!


Argentina
--Vz--
Previous Topic: How to write a description in a custom OpenVZ template?
Goto Forum:
  


Current Time: Thu Nov 23 18:38:15 GMT 2017