Need a simple script written

Discussion in 'OT Technology' started by Supernaut, Aug 21, 2004.

  1. Supernaut

    Supernaut New Member

    Joined:
    May 20, 2003
    Messages:
    8,047
    Likes Received:
    0
    I'm looking for a simple bandwidth monitor that will give me a realtime display. Something that would poll the readout of $ cat /proc/net/dev every second or so and do the math. This is on a machine that I only can access via SSH and with no root, so it would have to be a simple Perl script or possibly something in php, I dunno.

    For example, my current readout:
    Inter-| Receive | Transmit
    face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
    lo:420564482 778493 0 0 0 0 0 0 420564482 778493 0 0 0 0 0 0
    eth0:1629262341 251187270 75 14 53 0 0 0 3895482679 387013680 0 0 12 0 0 0

    In bold are the numbers the script would compute. Change in number div by time should do the trick.
     
  2. Supernaut

    Supernaut New Member

    Joined:
    May 20, 2003
    Messages:
    8,047
    Likes Received:
    0
  3. kosstamogen

    kosstamogen New Member

    Joined:
    Aug 26, 2004
    Messages:
    386
    Likes Received:
    0
    Location:
    SoCal
    I haven't done bash for 2 years so i'm pretty rusty. And I don't have a linux machine to play on...

    But I'd say you want to pipe that output into SED and awk and then out put those columns from awk. I suppose in sed you search for that "eth0" string then output those two columns that you have in bold. You can use a for loop to execute it every few seconds using Sleep. hope this helps somewhat...
     

Share This Page