forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cWrap.sh
executable file
·76 lines (57 loc) · 1.89 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
BASE_DIR=/data/unified/WmAgentScripts/
HTML_DIR=/data/unified/www
FINAL_HTML_DIR=/eos/cms/store/unified/www/
cd $BASE_DIR
if [ "$USER" != "vlimant" ] ; then
echo "single user running from now on"
exit
fi
modulename=`echo $1 | sed 's/\.py//' | sed 's/Unified\///'`
mkdir -p $HTML_DIR/logs/$modulename/
mkdir -p $FINAL_HTML_DIR/logs/$modulename/
last_log=$HTML_DIR/logs/$modulename/last.log
dated_log=$HTML_DIR/logs/$modulename/`date +%F_%T`.log
log=$dated_log
echo `date` > $log
if [ -r unified_drain ] ; then
echo "System is locally draining" >> $log
cp $log $last_log
cp $log $FINAL_HTML_DIR/logs/$modulename/.
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
cp $log $FINAL_HTML_DIR/logs/$modulename/.
cp $log $FINAL_HTML_DIR/logs/$modulename/last.log
exit
fi
echo $USER >> $log
echo $HOSTNAME >> $log
#echo the week $week oddity is $oddity >> $log
echo module $modulename>> $log
echo $MCM_SSO_COOKIE >>$log
echo $X509_USER_PROXY >>$log
source /data/srv/wmagent/current/apps/wmagent/etc/profile.d/init.sh
export PYTHONPATH=$PYTHONPATH:/usr/lib64/python2.7/site-packages
echo >> $log
start=`date +%s`
echo $modulename:`date` >> $FINAL_HTML_DIR/logs/running
echo $modulename:`date` > $FINAL_HTML_DIR/logs/last_running
python $* &>> $log
if [ $? == 0 ]; then
echo "finished" >> $log
else
echo "abnormal termination" >> $log
mail -s "[Ops] module "$modulename" failed" -a $log [email protected],[email protected],[email protected],[email protected]
fi
stop=`date +%s`
let stop=stop-start
echo $modulename:$start:$stop > $FINAL_HTML_DIR/logs/$modulename/`date +%s`.time
echo `date` >> $log
#cp $log $dated_log
cp $log $last_log
cp $log $FINAL_HTML_DIR/logs/$modulename/.
cp $log $FINAL_HTML_DIR/logs/$modulename/last.log
#rm $log