LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-19-2005, 05:55 AM   #1
epsharma
LQ Newbie
 
Registered: Jul 2005
Posts: 2

Rep: Reputation: 0
How to calculate bandwidth on linux


I have installed cbq to throttle bandwidth . I didnt know how to gauze/calculate the bandwidth on linux

I could not trace the log of cbq and at the same time no idea how to account bandwidth for different ruleset of cbq

Any help in this regard will be appreciated,

Thanks,
epsharma
 
Old 07-20-2005, 03:06 PM   #2
crep
Member
 
Registered: Aug 2004
Location: US
Distribution: Fedora, FBSD, Solaris
Posts: 46

Rep: Reputation: 15
OK check this out.

Everything in linux is logged, though usually we have no idea where. I'm sure somewhere in /proc/net there is a way to tell how many bits have gone in and out. But here's how I do it.

I assume here that you have snmpd installed and running, as well as net-snmp-tools. Type "ps -A|grep snmp" and "snmpwalk --help" to test this.

Start by typing this:

snmpwalk -v1 -cpublic <host> system

This should start spewing system info down your console. Each value is in the form:

sytem.thing1.thing2.thing3.etc = <whatever>

Look for something that looks like ifInOctets and ifOutOctets. Those are how many bytes have been passed in and out by the interface since last reboot (or last counter reset, but we don't need to get into that here.) Look at the path (ie the system.thing1.thing2 etc) for those values: I can't remember them offhand. Then, when you type:

snmpwalk -v1 -cpublic <host> system.path.to.those.values |grep Octets

You should see those two values.

NOW: if you want to know bandwidth at a particular interval, you obviously must take two snapshots of those values and divide the difference by the time between them: I'm not going to write how to script this here, but I've done it, it's not too hard.

OR: If you want to do this the easy way, there's a great tool called "IPTraf". You can install it by rpm or however you wish. Just become root, and type iptraf. It's got a pretty nice interface that tells you all about bandwidth stats and such.

Have fun.
 
Old 07-20-2005, 03:31 PM   #3
mikedeatworld
Member
 
Registered: Nov 2003
Location: Farmington Michigan
Distribution: UBUNTU - Slackware - SuSE 9.1 - Knoppix - Fedora
Posts: 828

Rep: Reputation: 30
www.nagios.com
 
Old 10-02-2005, 05:51 PM   #4
denver1980
Member
 
Registered: Dec 2004
Location: Québec
Distribution: Gentoo, Kubuntu Karmic
Posts: 48

Rep: Reputation: 15
I maid a small bash script to use bwm-ng
Code:
Fic_Tmp="/tmp/Fic_Tmp_VerifRatio.tmp"
NbrSec=20
/usr/local/Bwm/bin/bwm-ng -I eth0 -o csv -T avg -C " " -c ${NbrSec} | awk '
BEGIN{
   BytesS=0
   NbrLecture=0}
/eth0/&&NR>2{
   BytesS+=$5/1024
   NbrLecture+=1}
END{
   Ratio=BytesS/NbrLecture
}
      printf ("%4.0f", Ratio)}' > ${Fic_Tmp}

Ratio=$(cat ${Fic_Tmp})
rm ${Fic_Tmp}

if [ "${Ratio}" -lt 110 ];then
   echo "BW OK - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
   exit 0
else
   echo "BW Surchargé - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
   exit 2
fi
exit $?
It checks my bw on local machine for 20 secs ...
 
Old 07-02-2006, 10:45 AM   #5
paulchin
LQ Newbie
 
Registered: Aug 2003
Posts: 5

Rep: Reputation: 0
Unhappy

Quote:
Originally Posted by denver1980
I maid a small bash script to use bwm-ng
Code:
Fic_Tmp="/tmp/Fic_Tmp_VerifRatio.tmp"
NbrSec=20
/usr/local/Bwm/bin/bwm-ng -I eth0 -o csv -T avg -C " " -c ${NbrSec} | awk '
BEGIN{
   BytesS=0
   NbrLecture=0}
/eth0/&&NR>2{
   BytesS+=$5/1024
   NbrLecture+=1}
END{
   Ratio=BytesS/NbrLecture
}
      printf ("%4.0f", Ratio)}' > ${Fic_Tmp}

Ratio=$(cat ${Fic_Tmp})
rm ${Fic_Tmp}

if [ "${Ratio}" -lt 110 ];then
   echo "BW OK - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
   exit 0
else
   echo "BW Surchargé - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
   exit 2
fi
exit $?
It checks my bw on local machine for 20 secs ...
Hi, I get the following error:

awk: cmd. line:11: printf ("%4.0f", Ratio)}
awk: cmd. line:11: ^ syntax error
awk: cmd. line:11: printf ("%4.0f", Ratio)}
awk: cmd. line:11: ^ syntax error

Regards,
Paul
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vsftpd - how to limit download bandwidth but unlimited upload bandwidth? mpls mikeg Linux - Software 3 08-13-2005 01:52 PM
How does one calculate folder sizes in linux GryphonTech Linux - Newbie 2 10-23-2004 03:50 PM
Linux will not calculate my free space correctly on fat32 drive The_Last_Nerd Linux - Hardware 12 06-23-2004 03:42 PM
how to calculate shmmax when install Oracle in Linux exper Linux - Software 1 02-17-2004 05:15 AM
bandwidth management in linux basbosco Linux - Networking 1 11-06-2003 07:30 AM


All times are GMT -5. The time now is 06:01 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration