forked from davidsheffield/McMScripts
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgetMcMTestScript.sh
More file actions
executable file
·52 lines (44 loc) · 1.44 KB
/
getMcMTestScript.sh
File metadata and controls
executable file
·52 lines (44 loc) · 1.44 KB
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
#!/bin/bash
################################
#
# getMcMTestScript.sh
#
# Script to grab McM test script and run getTimeSize.sh.
#
# author: David G. Sheffield (Rutgers)
#
################################
prepid=""
outputFile="test.sh"
number=0
while [ "$1" != "" ]; do
case $1 in
-o) shift
outputFile=$1
;;
-n) shift
number=$1
;;
-h | --help) echo "Usage: sh getMcMTestScript.sh PrepID [-o outputFile] [-n numberOfEvents]"
exit
;;
*) prepid=$1
;;
esac
shift
done
echo "Getting test script for ${prepid} from McM."
curl --insecure https://cms-pdmv.cern.ch/mcm/public/restapi/requests/get_test/${prepid} -o ${outputFile}
sed -i '/grep/d' ${outputFile}
echo "n=\`grep "\""TotalEvents"\"" ${prepid}_rt.xml | awk 'BEGIN{FS="\"">"\""}{print \$2}' | awk 'BEGIN{FS="\""<"\""}{print \$1}'\`
echo "\""Events: "\""\$n
time=\`grep "\""AvgEventCPU"\"" ${prepid}_rt.xml | awk 'BEGIN{FS="\""\\"\"\""}{print \$4}'\`
echo "\""CPU Time [s]: "\""\$time
total_size=\`grep "\""Timing-tstoragefile-write-totalMegabytes"\"" ${prepid}_rt.xml | awk 'BEGIN{FS="\""\\"\"\""}{print \$4}'\`
avg_size=\`echo "\""\$total_size*1024/\$n"\"" | bc -l\` # Convert total size to kilobytes and calculate average per event
echo "\""Size [kB]: "\""\$avg_size
" >> ${outputFile}
if [ $number -gt 0 ]; then
sed -i "s/-n .* ||/-n ${number} ||/" ${outputFile}
sed -i "s/echo .* events were ran/echo ${number} events were run/" ${outputFile}
fi