ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/monitor.sh
Revision: 1.2
Committed: Thu Aug 9 21:16:03 2012 UTC (12 years, 8 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, HEAD
Changes since 1.1: +0 -1 lines
Log Message:
For version 029.

File Contents

# User Rev Content
1 paus 1.1 #!/bin/bash
2     #---------------------------------------------------------------------------------------------------
3     # Monitor progress of download into a given directory
4     #---------------------------------------------------------------------------------------------------
5     H=`basename $0`
6    
7     DIR=$1
8     PATTERN=$2
9    
10     # total size and starting point
11     startTime=$(date +%s)
12     totSize=`du -s --block-size=1G $DIR | cut -f1`
13     startSize=$totSize
14     lastSize=$totSize
15     lastTime=$(date +%s);
16    
17     while [ 1 -ge 0 ]
18     do
19    
20     nowTime=$(date +%s);
21     totSize=`du -s --block-size=1G $DIR | cut -f1`
22    
23     lastDuration=$(($nowTime - $lastTime))
24     lastAdded=$(($totSize - $lastSize))
25    
26     duration=$(($nowTime - $startTime))
27     totAdded=$(($totSize - $startSize))
28    
29     if [ $duration -gt 0 ] && [ $lastDuration -gt 0 ]
30     then
31     totRate=` echo h | awk "{ print $totAdded/$duration }"`
32     lastRate=`echo h | awk "{ print $lastAdded/$lastDuration }"`
33     else
34     totRate=0
35     lastRate=0
36     fi
37     clear
38     date=`date +"Refresh 100 sec -- last update %H:%M:%S [%d/%m/%y]"`
39     lCols=`stty size | cut -d' ' -f2`
40     printf "%${lCols}s" "$date"
41     echo " "
42     echo "==== Transfer rate to $DIR ===="
43     echo " "
44     if [ "$PATTERN" == "" ]
45     then
46     du -sh $DIR/* | tail -44
47     else
48     du -sh $DIR/* | grep $PATTERN
49     fi
50     echo " "
51     printf "==== Size [GB] : %6d (last: %6d) ====\n" $totSize $lastSize
52     printf "==== Rate [GB/sec]: %6.3f (last: %6.3f) ====\n" $totRate $lastRate
53     #echo "==== Size [GB] : $totSize (last: $lastSize) ===="
54     #echo "==== Rate [GB/sec]: $totRate (last: $lastRate) ===="
55     echo " "
56     #echo "== $duration - $lastDuration =="
57    
58     # update last status
59     lastSize=$totSize
60     lastTime=$nowTime
61    
62     # finally wait a bit
63     sleep 100
64    
65     done
66    
67     exit 0