Virtual ip Bandwidth Monitor Graphing.
Requirements
IPTables - mandatory
Perl - mandatory
RRDTool - only needed if you want the pretty graphs
Create a directory to store your files in.
You can use any directorys you want however you will need to edit the paths in each script.
mkdir /rrd
cd /rrd
mkdir scripts
mkdir db
mkdir /var/www/html/rrdgraphs
install rrdtool
the easiest way is to type
yum install rrdtool
if you have rrdtool installed type
whereis rrdtool
and remember where it is for later.
or
install from the source
type
wget http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/rrdtool-1.0.49.tar.gz
tar zxfv rrdtool-1.0.49.tar.gz
cd rrdtool-1.0.49
./configure
make
make install
make site-perl-install
Download This file into /rrd
wget http://www.piratehosting.net/ip_accountant.tar
tar xfv ip_accountant.tar
cd db
pico run2.sh
here you will add each ip you would like to graph, there is 10 ip in run2.sh however you can add as many as you need.
this creates the round robin databases required to track bandwidth usage.
rrdtool create 123.123.123.100.rrd \
--step 300 \
DS:rx:COUNTER:600:U:U \
DS:tx:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:2016
When done save the file with ctrl o and ctrl x
cd ../scripts
pico run.sh
there are 4 places here in each block requireing you to change to one of your ips.
I have added 10 ips in run.sh however you can add as many as you need.
this part creates your graphs you can play with size and color to suit your needs.
rrdtool graph /var/www/html/rrdgraphs/123.123.123.100.gif \
--title "123.123.123.100" \
--width 600 \
--color BACK#FFFFFF \
--color SHADEA#FFFFFF \
--color SHADEB#FFFFFF \
--color CANVAS#F0F0F0 \
--color GRID#CCCCCC \
--color MGRID#999999 \
--color FONT#000000 \
--color FRAME#FFFFFF \
--start -86400 \
--vertical-label "bytes/sec" \
--no-legend \
DEF:myrx=/rrd/db/123.123.123.100.rrd:rx:AVERAGE \
DEF:mytx=/rrd/db/123.123.123.100.rrd:tx:AVERAGE \
LINE1:myrx#FF0000:Rx \
LINE1:mytx#0000FF:Tx
continue till all your virtual ips are added.
pico rd.sh
this uses iptables to track your bandwidth usage.
change SUBNET1 to the 1st 3 digits of your virtual ips.
place final octec into the first1 and the last ip into the last1
Eg- 123.123.123 for SUBNET1
100 for FIRST1
110 for LAST1
ctrl o to save
ctrl x to exit
You will need to add each ip to your /etc/hosts file
type pico /etc/hosts
Do not remove anything here just goto the bottom and add each ip in 3 colunms.
123.123.123.100 123.123.123.100 123.123.123.100
123.123.123.101 123.123.123.101 123.123.123.101
123.123.123.102 123.123.123.102 123.123.123.102
And so on till you add all the virtual ips you want to graph.
type iptables -nL
pico ip_accountant.pl
here set the paths at the top of the script to that of your system
whereis iptables
whereis rrdtool
will find your paths
my $iptables = "/sbin/iptables";
my $rrdtool = "/usr/bin/rrdtool";
my $rrd_db_loc = "/rrd/db";
my $html_report = "/var/www/html/rrdgraphs/ip_accountant_include.html";
Setup in complete.
Start it up by running these commands.
cd /rrd/db
./run2.sh
cd ../scripts
./run.sh
./ip_accountant.pl
If everything works you will see usage on the active ips, if so goto the next step.
type
./ip_accountant.pl rrd
./ip_accountant.pl html
This will create the gif images and html to show your virual ip usage.
The last step is to add these items to cron.
*/5 * * * * root /rrd/scripts/ip_accountant rrd
*/5 * * * * root /rrd/scripts/ip_accountant html
*/5 * * * * root /rrd/scripts/run.sh > /dev/null
*/5 * * * * root /rrd/db/run2.sh > /dev/null
There you have it virtual ip graphing.
I also created a index.html page showing each .gif in a nice page instead of loose gifs but this isnt needed.
This took me about 30 minutes to setup my 1st time, it is alot to do at 1st but you will do good.
Post to this thread any questions you have, i have found that some firewall and iptable rules do not allow this to run correctly if this is the case shut them off and try.
Thanks to pedram amini
pedram@redhive.com
http://pedram.redhive.com
for creating this script.
Requirements
IPTables - mandatory
Perl - mandatory
RRDTool - only needed if you want the pretty graphs
Create a directory to store your files in.
You can use any directorys you want however you will need to edit the paths in each script.
mkdir /rrd
cd /rrd
mkdir scripts
mkdir db
mkdir /var/www/html/rrdgraphs
install rrdtool
the easiest way is to type
yum install rrdtool
if you have rrdtool installed type
whereis rrdtool
and remember where it is for later.
or
install from the source
type
wget http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/rrdtool-1.0.49.tar.gz
tar zxfv rrdtool-1.0.49.tar.gz
cd rrdtool-1.0.49
./configure
make
make install
make site-perl-install
Download This file into /rrd
wget http://www.piratehosting.net/ip_accountant.tar
tar xfv ip_accountant.tar
cd db
pico run2.sh
here you will add each ip you would like to graph, there is 10 ip in run2.sh however you can add as many as you need.
this creates the round robin databases required to track bandwidth usage.
rrdtool create 123.123.123.100.rrd \
--step 300 \
DS:rx:COUNTER:600:U:U \
DS:tx:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:2016
When done save the file with ctrl o and ctrl x
cd ../scripts
pico run.sh
there are 4 places here in each block requireing you to change to one of your ips.
I have added 10 ips in run.sh however you can add as many as you need.
this part creates your graphs you can play with size and color to suit your needs.
rrdtool graph /var/www/html/rrdgraphs/123.123.123.100.gif \
--title "123.123.123.100" \
--width 600 \
--color BACK#FFFFFF \
--color SHADEA#FFFFFF \
--color SHADEB#FFFFFF \
--color CANVAS#F0F0F0 \
--color GRID#CCCCCC \
--color MGRID#999999 \
--color FONT#000000 \
--color FRAME#FFFFFF \
--start -86400 \
--vertical-label "bytes/sec" \
--no-legend \
DEF:myrx=/rrd/db/123.123.123.100.rrd:rx:AVERAGE \
DEF:mytx=/rrd/db/123.123.123.100.rrd:tx:AVERAGE \
LINE1:myrx#FF0000:Rx \
LINE1:mytx#0000FF:Tx
continue till all your virtual ips are added.
pico rd.sh
this uses iptables to track your bandwidth usage.
change SUBNET1 to the 1st 3 digits of your virtual ips.
place final octec into the first1 and the last ip into the last1
Eg- 123.123.123 for SUBNET1
100 for FIRST1
110 for LAST1
ctrl o to save
ctrl x to exit
You will need to add each ip to your /etc/hosts file
type pico /etc/hosts
Do not remove anything here just goto the bottom and add each ip in 3 colunms.
123.123.123.100 123.123.123.100 123.123.123.100
123.123.123.101 123.123.123.101 123.123.123.101
123.123.123.102 123.123.123.102 123.123.123.102
And so on till you add all the virtual ips you want to graph.
type iptables -nL
pico ip_accountant.pl
here set the paths at the top of the script to that of your system
whereis iptables
whereis rrdtool
will find your paths
my $iptables = "/sbin/iptables";
my $rrdtool = "/usr/bin/rrdtool";
my $rrd_db_loc = "/rrd/db";
my $html_report = "/var/www/html/rrdgraphs/ip_accountant_include.html";
Setup in complete.
Start it up by running these commands.
cd /rrd/db
./run2.sh
cd ../scripts
./run.sh
./ip_accountant.pl
If everything works you will see usage on the active ips, if so goto the next step.
type
./ip_accountant.pl rrd
./ip_accountant.pl html
This will create the gif images and html to show your virual ip usage.
The last step is to add these items to cron.
*/5 * * * * root /rrd/scripts/ip_accountant rrd
*/5 * * * * root /rrd/scripts/ip_accountant html
*/5 * * * * root /rrd/scripts/run.sh > /dev/null
*/5 * * * * root /rrd/db/run2.sh > /dev/null
There you have it virtual ip graphing.
I also created a index.html page showing each .gif in a nice page instead of loose gifs but this isnt needed.
This took me about 30 minutes to setup my 1st time, it is alot to do at 1st but you will do good.
Post to this thread any questions you have, i have found that some firewall and iptable rules do not allow this to run correctly if this is the case shut them off and try.
Thanks to pedram amini
pedram@redhive.com
http://pedram.redhive.com
for creating this script.