ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VisualizationOperations/scripts/VisualizationClients/livelyiSpy.sh
Revision: 1.1
Committed: Thu Feb 25 16:32:11 2010 UTC (15 years, 2 months ago) by tboccali
Content type: application/x-sh
Branch: MAIN
CVS Tags: beforegetScenario, pp-15072011, pp-31032011, pp-11032011, pp-10032011, pp-03032011, pp-28022011, pp-21022011, pp-17022011, pp-10022011, HI-08112010, HI-04-11-2010, HI-03-11-2010, V191010, V02092010, V27072010, V26072010, V08072010, V08062010, V31032010-2, V31032010, V29032010-3, V29032010-2, V29032010, V27032010, V250312010, V23032010, lm230310, V19032010-2, V19032010, V18032010, V18022010, lm170310v3, lm170310v2, lm170310, V170302010, HEAD
Error occurred while calculating annotation data.
Log Message:
add file

File Contents

# Content
1 #! /bin/bash
2 #######################################################################################################
3 # #
4 #Script to periodically check if iguana is running and establish its current status to determine #
5 #if it must be restarted. #
6 # #
7 #based on Hyunkwan's alivecheck_dqmPostProcessing.sh #
8 # #
9 # Luis Ignacio Lopera lilopera@cern.ch #
10 # #
11 #######################################################################################################
12
13 #ispy --online srv-c2d05-15.cms:9000 /home/iSpy/cms-detector.ig
14
15 #Globals
16 IMAGE_DIR="/home/vis/EventDisplay/images"
17 DETECTOR_GEOMETRY="/home/iSpy/cms-detector.ig"
18 CUTS_ISS="/home/iSpy/cuts.iss"
19 VIEWS_IML="/home/iSpy/online-views.iml"
20 WORKING_DIR="/home/vis/iglogs"
21
22 #Client Names:
23 CLIENT0="P5"
24 CLIENT1="CMSCC"
25
26 #Producer Connection strings (--online ):
27 SRV_PORT_C0="vocms89:9001"
28 SRV_PORT_C1="vocms89:9000"
29
30 #Log files
31 igLOG_CLIENT0=$WORKING_DIR"/iSpylog_"$CLIENT0"_"`date +%Y%m%d_%H%M`"_"$HOSTNAME #Output grabber
32 igLOG_CLIENT1=$WORKING_DIR"/iSpylog_"$CLIENT1"_"`date +%Y%m%d_%H%M`"_"$HOSTNAME #Output grabber
33
34 igABORT_BASE_LOG_FILE="/home/iSpy/iglogs/igAbort" #Base file name for abort handeling
35 NUM_LINES=40 #Number of lines to log
36
37 #YourEmail=liloperavim@cern.ch
38 #cronjob entry: */10 * * * * /home/iSpy/iglogs/livelyiSpy.sh >> /home/iSpy/iglogs/ispyLiveCheck 2>&1
39 KDMPID=$([ $(stat -c %U /proc/$(/sbin/pidof -x /usr/bin/startkde)) == vis ] && /sbin/pidof -x /usr/bin/startkde)
40 GDMPID=$([ $(stat -c %U /proc/$(/sbin/pidof gnome-session)) == vis ] && /sbin/pidof gnome-session)
41 REASON="Unknown"
42
43 if [[ -z $KDMPID && -z $GDMPID ]]
44 then
45 exit
46 fi
47 if [ -z $KDMPID ]
48 then
49 eval `tr '\0' '\n' < /proc/$GDMPID/environ | grep XAUTHORITY`
50 else
51 eval `tr '\0' '\n' < /proc/$KDMPID/environ | grep XAUTHORITY`
52 fi
53
54 export XAUTHORITY
55
56 if [[ $1 =~ \-\-restart ]]
57 then
58 killall -9 ispy
59 REASON="Forced Restart"
60 fi
61
62 timestamp=$(date +%Y%m%d)
63 if [[ $HOSTNAME =~ scx5scr36* || $HOSTNAME =~ SCX5SCR36* ]]
64 then
65 names=$CLIENT0
66 dirs=$IMAGE_DIR/$timestamp/$CLIENT0
67 logfiles=$igLOG_CLIENT0
68 srvports=$SRV_PORT_C0
69 numClients=1
70 export DISPLAY=:0.0
71 else
72 names=$CLIENT1
73 dirs=$IMAGE_DIR/$timestamp/$CLIENT1
74 logfiles=$igLOG_CLIENT1
75 srvports=$SRV_PORT_C1
76 numClients=1
77 export DISPLAY=:0.0
78 fi
79 i=0
80 while [[ $i -lt $numClients ]]
81 do
82
83 pid=-1
84 RUN_STAT=0
85 if [ -e $WORKING_DIR/pid${names[$i]} ]
86 then
87 pid=$(cat $WORKING_DIR/pid${names[$i]})
88 RUN_STAT=$([[ $pid != "" ]] && echo $(ps -eo pid | grep -oP "\b${pid}\b" | grep -v grep | wc -l))
89 fi
90 if [[ $RUN_STAT -eq 0 ]]
91 then
92 if [ ! -d ${dirs[$i]} ]
93 then
94 mkdir -p ${dirs[$i]}
95 fi
96 export ISPY_AUTO_PRINT_PATH=${dirs[$i]}
97 export ISPY_AUTO_PRINT=1
98 echo /home/iSpy/ispy ${CUTS_ISS} ${VIEWS_IML} --online ${srvports[$i]} ${DETECTOR_GEOMETRY}
99 /home/iSpy/ispy ${CUTS_ISS} ${VIEWS_IML} --online ${srvports[$i]} ${DETECTOR_GEOMETRY} 1>${logfiles[$i]} 2>&1 &
100 echo $! > $WORKING_DIR/pid${names[$i]}
101 echo `date +"%Y/%m/%d %H:%M:%S"` WARNING: iSpy Online ${names[$i]} was not Running and has been restarted, reason: $REASON
102 echo `date +"%Y/%m/%d %H:%M:%S"` INFO: Creating logfile ${logfiles[$i]}
103 else
104 echo `date +"%Y/%m/%d %H:%M:%S"` INFO: iSpy Online ${names[$i]} Running
105 fi
106 i=$(( i + 1 ))
107 done