LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 11-06-2008, 11:45 AM   #1
Geneset
Member
 
Registered: Jan 2007
Location: Athlone, ROI
Distribution: Ubuntu Hardy Desktop, Solaris 10, Workstation 2008 x64
Posts: 75

Rep: Reputation: 16
Question Low level network interface download speed monitor


Hi folks
I have a MyBook World Edition and i wanted to write a script to control the lights on the front of it depending on the current download speed but wanted to do it in such a way that it wont run as a daemon but as a cronjob (doesnt need to be any more regular than every 10 minutes or so),
and as such, what i need is a way to get the numeric download speed.

I'm imagining catting from a /dev/....../something that would give me a "raw" reading rather than running ntop or something like that every time and parsing from that.

Sorry if im not explaining myself very well, so to summarise

How do i get the current speed of a network interface?

Regards
 
Old 11-06-2008, 12:03 PM   #2
Geneset
Member
 
Registered: Jan 2007
Location: Athlone, ROI
Distribution: Ubuntu Hardy Desktop, Solaris 10, Workstation 2008 x64
Posts: 75

Original Poster
Rep: Reputation: 16
I can get the totals for byte downloads from /sys/class/net/eth0/device/net:eth0/statistics/rx_bytes but if anyone knows any better way of getting the RATE of transfer that would be fantastic

Last edited by Geneset; 11-06-2008 at 12:07 PM. Reason: had rx_packets instead of rx_bytes
 
Old 11-06-2008, 01:16 PM   #3
Geneset
Member
 
Registered: Jan 2007
Location: Athlone, ROI
Distribution: Ubuntu Hardy Desktop, Solaris 10, Workstation 2008 x64
Posts: 75

Original Poster
Rep: Reputation: 16
Ok, so this is what i have and it will do for the time being
Code:
#!/bin/bash
INITIAL_RX=`cat /sys/class/net/eth0/device/net:eth0/statistics/rx_bytes`
sleep 10
FINAL_RX=`cat /sys/class/net/eth0/device/net:eth0/statistics/rx_bytes`
DELTA_RX=`expr $FINAL_RX - $INITIAL_RX`
KBPS_RX=`expr $DELTA_RX / 10240 `

let "RESULT = $KBPS_RX / 3"
echo $RESULT > "/sys/devices/platform/wdc-leds/leds:wdc-leds:fuel-gauge/brightness"
then to get it to run every 5 mins add this to the crontab (obv change the location of the script, but im lazy
*/5 * * * * /root/rate.bsh
 
  


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
Limit the speed of a network interface. exodist Linux - Networking 8 08-15-2008 10:37 PM
Network card realtek 8139 big latency and low speed onion Linux - Newbie 6 02-03-2008 09:53 AM
download speed is very low. bruse Linux - Networking 4 01-12-2006 06:08 AM
Setting Network Interface Speed ITJedi Linux - Networking 4 05-14-2004 11:02 PM
Is there a tool to monitor Internet connection speed and also network speed? xleft4dexy Linux - Networking 4 10-14-2003 10:29 PM


All times are GMT -5. The time now is 03:26 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