Changeset 8858 for trunk/MagicSoft/Mars
- Timestamp:
- 02/08/08 16:13:50 (17 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8857 r8858 24 24 - added check to prevent that checksums of files not read from tape 25 25 enter the .lapalma file 26 27 * datacenter/scripts/dbchk 28 - added check for crashed runs, sequences and datasets 29 - corrected bugs in find command and $dir-loops 30 - adapted to the automatic concept and added it to the cronjobs 26 31 27 32 -
trunk/MagicSoft/Mars/datacenter/scripts/dbchk
r8380 r8858 1 1 #!/bin/sh 2 3 4 # SETUP 5 6 # directory where the sequence files are stored 7 sequencedir=/magic/sequences 8 callistodir=/magic/data/callisto 9 stardir=/magic/data/star 10 # access to the sql database 11 alias mymysql='mysql -s -u MAGIC -h vela --password=d99swMT!' 12 # database name 13 db=MyMagic 14 15 2 # 3 # ======================================================================== 4 # 5 # * 6 # * This file is part of MARS, the MAGIC Analysis and Reconstruction 7 # * Software. It is distributed to you in the hope that it can be a useful 8 # * and timesaving tool in analysing Data of imaging Cerenkov telescopes. 9 # * It is distributed WITHOUT ANY WARRANTY. 10 # * 11 # * Permission to use, copy, modify and distribute this software and its 12 # * documentation for any purpose is hereby granted without fee, 13 # * provided that the above copyright notice appear in all copies and 14 # * that both that copyright notice and this permission notice appear 15 # * in supporting documentation. It is provided "as is" without express 16 # * or implied warranty. 17 # * 18 # 19 # 20 # Author(s): Thomas Bretz 03/2007 <mailto:tbretz@astro.uni-wuerzburg.de> 21 # Author(s): Daniela Dorner 02/2008 <mailto:dorner@astro.uni-wuerzburg.de> 22 # Author(s): Stefan Ruegamer 02/2008 <mailto:snruegam@astro.uni-wuerzburg.de> 23 # 24 # Copyright: MAGIC Software Development, 2000-2008 25 # 26 # 27 # ======================================================================== 28 # 29 # This script searches for crashed runs, sequences or datasets in the db 30 # as well as obsolete or missing sequence files and corresponding callisto 31 # and star folders. In the third and fourth check the consistency between 32 # the Run and Sequence DB is checked. 33 # 34 # 16 35 # TODO 17 36 # 18 37 # Spped up with SQL: FIELD(25123, 1, 2, 3, 4, 5, ..., 1000200); 19 38 # Cross check sequences in Sequence and other databases … … 23 42 24 43 44 source `dirname $0`/sourcefile 45 printprocesslog "INFO starting $0" 46 program=dbchk 47 48 scriptlog=$runlogpath/$program-$datetime.log 49 date >> $scriptlog 2>&1 50 51 getdbsetup 52 alias mymysql='mysql -s -u $us --password=$pw --host=vela $db' 53 54 # check for crashed runs, sequences and datasets 55 echo "Checking if something is crashed on run basis" >> $scriptlog 2>&1 56 cruns=`echo "SELECT fRunNumber FROM RunProcessStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()" | mymysql` 57 if [ ! "$cruns" = "" ] 58 then 59 printprocesslog "WARN The following runs seem to be crashed. Please check manually: $cruns" 60 echo "WARN The following runs seem to be crashed. Please check manually: $cruns" >> $scriptlog 2>&1 61 else 62 echo " Nothing found." >> $scriptlog 2>&1 63 fi 64 65 echo "Checking if something is crashed on sequence basis" >> $scriptlog 2>&1 66 csequences=`echo "SELECT fSequenceFirst FROM SequenceProcessStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()" | mymysql` 67 if [ ! "$csequences" = "" ] 68 then 69 printprocesslog "WARN The following sequences seem to be crashed. Please check manually: $csequences" 70 echo "WARN The following sequences seem to be crashed. Please check manually: $csequences" >> $scriptlog 2>&1 71 else 72 echo " Nothing found." >> $scriptlog 2>&1 73 fi 74 75 echo "Checking if something is crashed on dataset basis" >> $scriptlog 2>&1 76 cdatasets=`echo "SELECT fDataSetNumber FROM DataSetProcessStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()" | mymysql` 77 if [ ! "$cdatasets" = "" ] 78 then 79 printprocesslog "WARN The following datasets seem to be crashed. Please check manually: $cdatasets" 80 echo "WARN The following datasets seem to be crashed. Please check manually: $cdatasets" >> $scriptlog 2>&1 81 else 82 echo " Nothing found." >> $scriptlog 2>&1 83 fi 84 25 85 # CHECK 1 26 echo Checking if all sequence files have a corresponding entry in Sequences27 files=`find $sequ encedir-type f`86 echo "Checking if all sequence files have a corresponding entry in Sequences" >> $scriptlog 2>&1 87 files=`find $sequpath -type f` 28 88 for file in $files 29 89 do … … 31 91 if [ "$sequence" = "" ] 32 92 then 33 echo No sequence file: $file93 echo "No sequence file: $file" >> $scriptlog 2>&1 34 94 continue 35 95 fi 36 37 var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`96 97 var=`echo SELECT fSequenceFirst FROM Sequences WHERE fSequenceFirst=$sequence | mymysql` 38 98 if ! [ "$sequence" = "$var" ] 39 99 then 40 echo Sequence-File $sequence exist but it is not in Sequences.100 echo "Sequence-File $sequence exist but it is not in Sequences." >> $scriptlog 2>&1 41 101 continue 42 102 fi … … 44 104 45 105 # CHECK 1b (callisto) 46 echo Checking if all sequences in $callistodir have a corresponding sequence in Sequence47 dirs=`find $ callistodir-type d`106 echo "Checking if all sequences in ${datapath}/callisto have a corresponding sequence in Sequence" >> $scriptlog 2>&1 107 dirs=`find ${datapath}/callisto -mindepth 2 -maxdepth 2 -type d` 48 108 for dir in $dirs 49 109 do 50 sequence=`echo $ file| sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`110 sequence=`echo $dir | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"` 51 111 if [ "$sequence" = "" ] 52 112 then 53 echo Invalid directory: $dir113 echo "Invalid directory: $dir" >> $scriptlog 2>&1 54 114 continue 55 115 fi 56 57 var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`116 117 var=`echo SELECT fSequenceFirst FROM Sequences WHERE fSequenceFirst=$sequence | mymysql` 58 118 if ! [ "$sequence" = "$var" ] 59 119 then 60 echo $dir exists but no corresponding sequence in Sequences.120 echo "$dir exists but no corresponding sequence in Sequences." >> $scriptlog 2>&1 61 121 continue 62 122 fi … … 64 124 65 125 # CHECK 1c (star) 66 echo Checking if all sequences in $stardir have a corresponding sequence in Sequence67 dirs=`find $ stardir-type d`126 echo "Checking if all sequences in ${datapath}/star have a corresponding sequence in Sequence" >> $scriptlog 2>&1 127 dirs=`find ${datapath}/star -mindepth 2 -type d` 68 128 for dir in $dirs 69 129 do 70 sequence=`echo $ file| sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`130 sequence=`echo $dir | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"` 71 131 if [ "$sequence" = "" ] 72 132 then 73 echo Invalid directory: $dir133 echo "Invalid directory: $dir" >> $scriptlog 2>&1 74 134 continue 75 135 fi 76 77 var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`136 137 var=`echo SELECT fSequenceFirst FROM Sequences WHERE fSequenceFirst=$sequence | mymysql` 78 138 if ! [ "$sequence" = "$var" ] 79 139 then 80 echo $dir exists but no corresponding sequence in Sequences.140 echo "$dir exists but no corresponding sequence in Sequences." >> $scriptlog 2>&1 81 141 continue 82 142 fi … … 84 144 85 145 # CHECK 2 86 echo Checking if all sequences in Sequences have a corresponding sequence files87 sequences=`echo SELECT fSequenceFirst FROM $db.Sequences | mymysql`146 echo "Checking if all sequences in Sequences have a corresponding sequence files" >> $scriptlog 2>&1 147 sequences=`echo SELECT fSequenceFirst FROM Sequences | mymysql` 88 148 for sequence in $sequences 89 149 do 90 var=`find $sequ encedir-type f -regex .*/sequence0+${sequence}\.txt$`150 var=`find $sequpath -type f -regex .*/sequence0+${sequence}\.txt$` 91 151 if [ "$var" = "" ] 92 152 then 93 echo Sequence-File for $sequence not found but in db.153 echo "Sequence-File for $sequence not found but in db." >> $scriptlog 2>&1 94 154 fi 95 155 done 96 156 97 157 # CHECK 3 98 echo Checking if all sequences from Sequences exists RunData99 sequences=`echo SELECT fSequenceFirst FROM $db.Sequences GROUP BY fSequenceFirst | mymysql`158 echo "Checking if all sequences from Sequences exists RunData" >> $scriptlog 2>&1 159 sequences=`echo SELECT fSequenceFirst FROM Sequences GROUP BY fSequenceFirst | mymysql` 100 160 for sequence in $sequences 101 161 do 102 res=`echo SELECT fSequenceFirst FROM $db.RunData WHERE fSequenceFirst=$sequence GROUP BY fSequenceFirst | mymysql`162 res=`echo SELECT fSequenceFirst FROM RunData WHERE fSequenceFirst=$sequence GROUP BY fSequenceFirst | mymysql` 103 163 if ! [ "$sequence" = "$res" ] 104 164 then 105 echo Sequence $sequence exists in Sequences but not in RunData.165 echo "Sequence $sequence exists in Sequences but not in RunData." >> $scriptlog 2>&1 106 166 continue 107 167 fi … … 109 169 110 170 # CHECK 4 111 echo Checking if all sequences from RunData exists in Sequences112 sequences=`echo SELECT fSequenceFirst FROM $db.RunData WHERE not fSequenceFirst=0 GROUP BY fSequenceFirst | mymysql`171 echo "Checking if all sequences from RunData exists in Sequences" >> $scriptlog 2>&1 172 sequences=`echo SELECT fSequenceFirst FROM RunData WHERE not fSequenceFirst=0 GROUP BY fSequenceFirst | mymysql` 113 173 for sequence in $sequences 114 174 do 115 var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`175 var=`echo SELECT fSequenceFirst FROM Sequences WHERE fSequenceFirst=$sequence | mymysql` 116 176 if ! [ "$sequence" = "$var" ] 117 177 then 118 echo Sequence $sequence exists in RunData but not in Sequences.178 echo "Sequence $sequence exists in RunData but not in Sequences." >> $scriptlog 2>&1 119 179 continue 120 180 fi 121 181 done 122 182 183 finish >> $scriptlog 2>&1
Note:
See TracChangeset
for help on using the changeset viewer.