This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
cWrap.sh
executable file
·80 lines (63 loc) · 2.23 KB
/
cWrap.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
77
78
79
80
BASE_DIR=/data/unified/WmAgentScripts/
HTML_DIR=/data/unified/www
FINAL_HTML_DIR=/eos/cms/store/unified/www/
if [ ! -d $FINAL_HTML_DIR ] ; then
echo "Cannot read the log destination",$FINAL_HTML_DIR
exit
fi
cd $BASE_DIR
modulename=`echo $1 | sed 's/\.py//' | sed 's/Unified\///'`
mkdir -p $HTML_DIR/logs/$modulename/
env EOS_MGM_URL=root://eoscms.cern.ch eos mkdir -p $FINAL_HTML_DIR/logs/$modulename/
last_log=$HTML_DIR/logs/$modulename/last.log
s_dated_log=$modulename/`date +%F_%T`.log
dated_log=$HTML_DIR/logs/$s_dated_log
log=$dated_log
echo `date` > $log
echo $$ >> $log
if [ -r unified_drain ] ; then
echo "System is locally draining" >> $log
cp $log $last_log
env EOS_MGM_URL=root://eoscms.cern.ch eos cp $log $FINAL_HTML_DIR/logs/$modulename/.
env EOS_MGM_URL=root://eoscms.cern.ch eos cp $log $FINAL_HTML_DIR/logs/$modulename/last.log
exit
fi
if [ -r /eos/cms/store/unified/unified_drain ] ; then
echo "System is globally draining" >> $log
cp $log $last_log
env EOS_MGM_URL=root://eoscms.cern.ch eos cp $log $FINAL_HTML_DIR/logs/$modulename/.
env EOS_MGM_URL=root://eoscms.cern.ch eos cp $log $FINAL_HTML_DIR/logs/$modulename/last.log
exit
fi
echo $USER >> $log
echo $HOSTNAME >> $log
echo module $modulename>> $log
source ./set.sh
echo >> $log
start=`date +%s`
python ssi.py $modulename $start
python $* &>> $log
if [ $? == 0 ]; then
echo "finished" >> $log
else
echo -e "\nAbnormal termination with exit code $?" >> $log
top -n1 -o %MEM -c >> $log
emaillog=$log.txt
failed_pid=$!
echo "Abnormal termination, check $log" > $emaillog
echo "https://cms-unified.web.cern.ch/cms-unified/logs/$s_dated_log" >> $emaillog
echo $failed_pid >> $emaillog
echo $USER >> $emaillog
echo $HOSTNAME >> $emaillog
echo -e "module $modulename \n" >> $emaillog
tail $log >> $emaillog
cat $emaillog | mail -s "[Ops] module "$modulename" failed" [email protected]
fi
stop=`date +%s`
python ssi.py $modulename $start $stop
echo `date` >> $log
#cp $log $dated_log
cp $log $last_log
env EOS_MGM_URL=root://eoscms.cern.ch eos cp $log $FINAL_HTML_DIR/logs/$modulename/.
env EOS_MGM_URL=root://eoscms.cern.ch eos cp $log $FINAL_HTML_DIR/logs/$modulename/last.log
#rm $log