Official Gitbrew Forums
These forums cover all aspects of the Gitbrew biosphere. If you would like your development project to be based here, ask an admin.

Home » General » GitFixed » fsiomon.sh (Bash script to determine how fast a file is being written to)
fsiomon.sh [message #29] Mon, 07 November 2011 06:13
iadnah is currently offline  iadnah
Messages: 25
Registered: July 2011
Gitbrew Noob
GPG/PGP Key
Administrator

Save as fsiomon.sh, chmod +x fsiomon.sh, and then use it like this:

./fsiomon.sh /somefile.bz2

It will tell you (roughly) how fast the file is growing. I wrote this to determine what kind of throughput I get when moving files over network mounted filesystems.

#!/bin/sh

FILE=$1

if [ ! -e ${FILE} ]; then
        exit $(false)
fi

function get_size() {
        stat -c %s $1
}


size_a=$(get_size ${FILE})
sleep 1
size_b=$(get_size ${FILE})

if [ $size_b -gt $size_a ]; then
        TRANS=$(($size_b - $size_a))

        if [ $TRANS -gt 1048576 ]; then
                OUT=$(($TRANS / 1048576))
                UNIT="MB/s"
        elif [ $TRANS -gt 1024 ]; then
                OUT=$(($TRANS / 1024))
                UNIT="KB/s"
        else
                OUT=$TRANS
                UNIT="Bytes/s"
        fi

        echo "${FILE} ${TRANS} ${OUT} ${UNIT}"
else
        echo "${FILE} not growing"
fi

Next Topic: Edit menus in XFCE4.8
Goto Forum:
  


Current Time: Tue Jun 18 23:18:25 CEST 2013

Total time taken to generate the page: 0.01864 seconds