Revision: | 1.1 |
Committed: | Thu Jan 6 22:42:02 2011 UTC (14 years, 4 months ago) by paus |
Content type: | application/x-sh |
Branch: | MAIN |
CVS Tags: | Mit_025c_branch2, Mit_025c_branch1, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018 |
Branch point for: | Mit_025c_branch |
Log Message: | Adding more powerful copy. |
# | Content |
---|---|
1 | #!/bin/bash |
2 | #--------------------------------------------------------------------------------------------------- |
3 | # Monitor progress of download into a given directory |
4 | #--------------------------------------------------------------------------------------------------- |
5 | H=`basename $0` |
6 | |
7 | ## DIR=/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/paus/filefi/015 |
8 | DIR=$1 |
9 | PATTERN=$2 |
10 | |
11 | # total size and starting point |
12 | startTime=$(date +%s) |
13 | totSize=`du -s --block-size=1G $DIR | cut -f1` |
14 | startSize=$totSize |
15 | lastSize=$totSize |
16 | lastTime=$(date +%s); |
17 | |
18 | while [ 1 -ge 0 ] |
19 | do |
20 | |
21 | nowTime=$(date +%s); |
22 | totSize=`du -s --block-size=1G $DIR | cut -f1` |
23 | |
24 | lastDuration=$(($nowTime - $lastTime)) |
25 | lastAdded=$(($totSize - $lastSize)) |
26 | |
27 | duration=$(($nowTime - $startTime)) |
28 | totAdded=$(($totSize - $startSize)) |
29 | |
30 | if [ $duration -gt 0 ] && [ $lastDuration -gt 0 ] |
31 | then |
32 | totRate=` echo h | awk "{ print $totAdded/$duration }"` |
33 | lastRate=`echo h | awk "{ print $lastAdded/$lastDuration }"` |
34 | else |
35 | totRate=0 |
36 | lastRate=0 |
37 | fi |
38 | clear |
39 | date=`date +"Refresh 100 sec -- last update %H:%M:%S [%d/%m/%y]"` |
40 | lCols=`stty size | cut -d' ' -f2` |
41 | printf "%${lCols}s" "$date" |
42 | echo " " |
43 | echo "==== Transfer rate to $DIR ====" |
44 | echo " " |
45 | if [ "$PATTERN" == "" ] |
46 | then |
47 | du -sh $DIR/* | tail -44 |
48 | else |
49 | du -sh $DIR/* | grep $PATTERN |
50 | fi |
51 | echo " " |
52 | printf "==== Size [GB] : %6d (last: %6d) ====\n" $totSize $lastSize |
53 | printf "==== Rate [GB/sec]: %6.3f (last: %6.3f) ====\n" $totRate $lastRate |
54 | #echo "==== Size [GB] : $totSize (last: $lastSize) ====" |
55 | #echo "==== Rate [GB/sec]: $totRate (last: $lastRate) ====" |
56 | echo " " |
57 | #echo "== $duration - $lastDuration ==" |
58 | |
59 | # update last status |
60 | lastSize=$totSize |
61 | lastTime=$nowTime |
62 | |
63 | # finally wait a bit |
64 | sleep 100 |
65 | |
66 | done |
67 | |
68 | exit 0 |