-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfah.sh
executable file
·76 lines (62 loc) · 1.94 KB
/
sfah.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash --noprofile
# Copyright (c) 2019 Moles & Halitosis
# Oct 2019 - choose a folding slot with FOLDSLOT
# Calculates rates and shows current percent completion
# of f@h client in the fah directory
# the regular expression pattern for the work unit
WORKUNIT=WU0.
# The slot you want to monitor
FOLDSLOT=${FOLDSLOT:-FS01}
# The F@H log file
FAHLOG=${FAHLOG:-/home/yourusername/yourFAHdir/log.txt}
declare -a fahStatus fahRate
#set -x
current_datetime(){
TZ=UTC date +'%H:%M:%S'
}
change_datetime_to_seconds(){
local dt=$1 # grab the datetime
local dth dtm dts # hour min sec holders
local dtt # total time in sec
dth=$(echo $dt | cut -s -d: -f1 | sed 's/^0//')
dtm=$(echo $dt | cut -s -d: -f2 | sed 's/^0//')
dts=$(echo $dt | cut -s -d: -f3 | sed 's/^0//')
dtt=$(($dth * 3600 + $dtm * 60 + $dts))
echo $dtt
}
most_recent_points(){
grep ":${FOLDSLOT}:Final credit estimate" "$FAHLOG" | tail -n1 | tr ',' ':' | cut -s -d: -f1-3,7
# do awk stuff here, if you can
}
current_fahstatus(){
local line n=0
for line in $(grep ":$WORKUNIT:$FOLDSLOT:....:Completed" "$FAHLOG" | tail -n 5 | tr '()' '::' | cut -s -d: -f1-3,8)
do
fahStatus[$n]="$line":"$(change_datetime_to_seconds $line)"
echo Were $line $(change_datetime_to_seconds $line)
: $(( n++ ))
done
}
fold_rate(){
lastRow=$(( ${#fahStatus[*]} - 2 ))
for row in $(seq 0 $lastRow)
do
iT=$(echo ${fahStatus[$row]} | cut -s -d: -f5)
jT=$(echo ${fahStatus[((row + 1))]} | cut -s -d: -f5)
if [ $iT -lt $jT ]
then
fahRate[(( $row + 1 ))]=$(( jT - iT ))
tT=$((tT + fahRate[(($row + 1))]))
else
echo "row $row:" $iT $jT ${fahStatus[$row]} ${fahStatus[(($row + 1))]} >&2
fi
done
tT=$(( $tT / (${#fahStatus[*]} - 1) ))
}
DT=$(current_datetime)
current_fahstatus
fold_rate
echo "Now " $DT ' ' $(change_datetime_to_seconds $DT)
#echo fahStatus length: ${#fahStatus[@]}
echo $(echo ${fahStatus[4]}|cut -s -d: -f1-3) $(echo ${fahStatus[4]}|cut -s -d: -f4) Avg: ${tT}s
most_recent_points