Changeset 8858 for trunk


Ignore:
Timestamp:
02/08/08 16:13:50 (17 years ago)
Author:
snruegam
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8857 r8858  
    2424     - added check to prevent that checksums of files not read from tape
    2525       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
    2631
    2732
  • trunk/MagicSoft/Mars/datacenter/scripts/dbchk

    r8380 r8858  
    11#!/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#
    1635# TODO
    17 
     36#
    1837# Spped up with SQL: FIELD(25123, 1, 2, 3, 4, 5, ..., 1000200);
    1938# Cross check sequences in Sequence and other databases
     
    2342
    2443
     44source `dirname $0`/sourcefile
     45printprocesslog "INFO starting $0"
     46program=dbchk
     47
     48scriptlog=$runlogpath/$program-$datetime.log
     49date >> $scriptlog 2>&1
     50
     51getdbsetup
     52alias mymysql='mysql -s -u $us --password=$pw --host=vela $db'
     53
     54# check for crashed runs, sequences and datasets
     55echo "Checking if something is crashed on run basis" >> $scriptlog 2>&1
     56cruns=`echo "SELECT fRunNumber FROM RunProcessStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()" | mymysql`
     57if [ ! "$cruns" = "" ]
     58then
     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
     61else
     62   echo " Nothing found." >> $scriptlog 2>&1
     63fi
     64
     65echo "Checking if something is crashed on sequence basis" >> $scriptlog 2>&1
     66csequences=`echo "SELECT fSequenceFirst FROM SequenceProcessStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()" | mymysql`
     67if [ ! "$csequences" = "" ]
     68then
     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
     71else
     72   echo " Nothing found." >> $scriptlog 2>&1
     73fi
     74
     75echo "Checking if something is crashed on dataset basis" >> $scriptlog 2>&1
     76cdatasets=`echo "SELECT fDataSetNumber FROM DataSetProcessStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()"  | mymysql`
     77if [ ! "$cdatasets" = "" ]
     78then
     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
     81else
     82   echo " Nothing found." >> $scriptlog 2>&1
     83fi
     84
    2585# CHECK 1
    26 echo Checking if all sequence files have a corresponding entry in Sequences
    27 files=`find $sequencedir -type f`
     86echo "Checking if all sequence files have a corresponding entry in Sequences" >> $scriptlog 2>&1
     87files=`find $sequpath -type f`
    2888for file in $files
    2989do
     
    3191   if [ "$sequence" = "" ]
    3292   then
    33       echo No sequence file: $file
     93      echo "No sequence file: $file" >> $scriptlog 2>&1
    3494      continue
    3595   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`
    3898   if ! [ "$sequence" = "$var" ]
    3999   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
    41101      continue
    42102   fi
     
    44104
    45105# CHECK 1b (callisto)
    46 echo Checking if all sequences in $callistodir have a corresponding sequence in Sequence
    47 dirs=`find $callistodir -type d`
     106echo "Checking if all sequences in ${datapath}/callisto have a corresponding sequence in Sequence" >> $scriptlog 2>&1
     107dirs=`find ${datapath}/callisto -mindepth 2 -maxdepth 2 -type d`
    48108for dir in $dirs
    49109do
    50    sequence=`echo $file | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
     110   sequence=`echo $dir | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
    51111   if [ "$sequence" = "" ]
    52112   then
    53       echo Invalid directory: $dir
     113      echo "Invalid directory: $dir" >> $scriptlog 2>&1
    54114      continue
    55115   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`
    58118   if ! [ "$sequence" = "$var" ]
    59119   then
    60       echo $dir exists but no corresponding sequence in Sequences.
     120      echo "$dir exists but no corresponding sequence in Sequences." >> $scriptlog 2>&1
    61121      continue
    62122   fi
     
    64124
    65125# CHECK 1c (star)
    66 echo Checking if all sequences in $stardir have a corresponding sequence in Sequence
    67 dirs=`find $stardir -type d`
     126echo "Checking if all sequences in ${datapath}/star have a corresponding sequence in Sequence" >> $scriptlog 2>&1
     127dirs=`find ${datapath}/star -mindepth 2 -type d`
    68128for dir in $dirs
    69129do
    70    sequence=`echo $file | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
     130   sequence=`echo $dir | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
    71131   if [ "$sequence" = "" ]
    72132   then
    73       echo Invalid directory: $dir
     133      echo "Invalid directory: $dir" >> $scriptlog 2>&1
    74134      continue
    75135   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`
    78138   if ! [ "$sequence" = "$var" ]
    79139   then
    80       echo $dir exists but no corresponding sequence in Sequences.
     140      echo "$dir exists but no corresponding sequence in Sequences." >> $scriptlog 2>&1
    81141      continue
    82142   fi
     
    84144
    85145# CHECK 2
    86 echo Checking if all sequences in Sequences have a corresponding sequence files
    87 sequences=`echo SELECT fSequenceFirst FROM $db.Sequences | mymysql`
     146echo "Checking if all sequences in Sequences have a corresponding sequence files" >> $scriptlog 2>&1
     147sequences=`echo SELECT fSequenceFirst FROM Sequences | mymysql`
    88148for sequence in $sequences
    89149do
    90    var=`find $sequencedir -type f -regex .*/sequence0+${sequence}\.txt$`
     150   var=`find $sequpath -type f -regex .*/sequence0+${sequence}\.txt$`
    91151   if [ "$var" = "" ]
    92152   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
    94154   fi
    95155done
    96156
    97157# CHECK 3
    98 echo Checking if all sequences from Sequences exists RunData
    99 sequences=`echo SELECT fSequenceFirst FROM $db.Sequences GROUP BY fSequenceFirst | mymysql`
     158echo "Checking if all sequences from Sequences exists RunData" >> $scriptlog 2>&1
     159sequences=`echo SELECT fSequenceFirst FROM Sequences GROUP BY fSequenceFirst | mymysql`
    100160for sequence in $sequences
    101161do
    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`
    103163   if ! [ "$sequence" = "$res" ]
    104164   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
    106166      continue
    107167   fi
     
    109169
    110170# CHECK 4
    111 echo Checking if all sequences from RunData exists in Sequences
    112 sequences=`echo SELECT fSequenceFirst FROM $db.RunData WHERE not fSequenceFirst=0 GROUP BY fSequenceFirst | mymysql`
     171echo "Checking if all sequences from RunData exists in Sequences" >> $scriptlog 2>&1
     172sequences=`echo SELECT fSequenceFirst FROM RunData WHERE not fSequenceFirst=0 GROUP BY fSequenceFirst | mymysql`
    113173for sequence in $sequences
    114174do
    115    var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
     175   var=`echo SELECT fSequenceFirst FROM Sequences WHERE fSequenceFirst=$sequence | mymysql`
    116176   if ! [ "$sequence" = "$var" ]
    117177   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
    119179      continue
    120180   fi
    121181done
    122182
     183finish >> $scriptlog 2>&1
Note: See TracChangeset for help on using the changeset viewer.