Index: trunk/MagicSoft/Mars/datacenter/scripts/filesondisk
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/filesondisk	(revision 7938)
+++ trunk/MagicSoft/Mars/datacenter/scripts/filesondisk	(revision 7944)
@@ -46,33 +46,26 @@
 
 source `dirname $0`/sourcefile
+printprocesslog "INFO starting $0"
+program=filesondisk
 
 set -C
 
-cd $mars
-
-program=filesondisk
-
-lockfile=$lockpath/lock-$program.txt
-
-scriptlogpath=$runlogpath/$program
-makedir $scriptlogpath
-scriptlog=$scriptlogpath/$program-$datetime.log
-
+scriptlog=$runlogpath/$program-$datetime.log
 date >> $scriptlog 2>&1
 
 # check if script is already running
+lockfile=$lockpath/lock-$program.txt
 checklock  >> $scriptlog 2>&1
 
-date=`date +%F`
+filesondisklogpath=$logpath/$program/`date +%Y/%m`
+makedir $filesondisklogpath >> $scriptlog 2>&1
 
-subsystemdir=/magic/subsystemdata
-filesondisklogpath=$logpath/$program/`date +%Y/%m`
-makedir $filesondisklogpath 
-
+cd $mars
 
 echo "checking disk for ccfiles..."  >> $scriptlog 2>&1
+printprocesslog "INFO checking ccfiles"
 filename=$filesondisklogpath/ccfilesondisk-$datetime.txt
 column=fCCFileAvail
-find $subsystemdir/cc/ -name '*_S.rep' | cut -d_ -f2  > $filename
+find $subsystempath/cc/ -name '*_S.rep' | cut -d_ -f2  > $filename
 
 echo "resetting runs..." >> $scriptlog 2>&1
@@ -80,13 +73,21 @@
 
 case $check3 in 
-   1)   echo "check3=$check3 -> everything ok -> reset is done" >> $scriptlog 2>&1 ;;
-   *)   echo "check3=$check3 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 ;;
+   1)   echo " check3=$check3 -> everything ok -> reset is done" >> $scriptlog 2>&1 
+        printprocesslog "INFO ccfiles resetted successfully"
+        ;;
+   0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+        printprocesslog "WARN connection to DB failed"
+        ;;
+   *)   echo " check3=$check3 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 
+        printprocesslog "ERROR resettallruns.C failed for ccfiles"
+        ;;
 esac
 
 
 echo "checking disk for cacofiles..."  >> $scriptlog 2>&1 
+printprocesslog "INFO checking cacofiles"
 filename=$filesondisklogpath/cacofilesondisk-$datetime.txt
 column=fCaCoFileAvail
-find $subsystemdir/caco/ -name '*.txt' | cut -d_ -f8 | grep [0-9] > $filename
+find $subsystempath/caco/ -name '*.txt' | cut -d_ -f8 | grep [0-9] > $filename
 
 echo "resetting runs..." >> $scriptlog 2>&1 
@@ -94,16 +95,33 @@
 
 case $check0 in 
-   1)   echo "check0=$check0 -> everything ok -> reset is done" >> $scriptlog 2>&1 ;;
-   *)   echo "check0=$check0 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 ;;
+   1)   echo " check0=$check0 -> everything ok -> reset is done" >> $scriptlog 2>&1 
+        printprocesslog "INFO cacofiles resetted successfully"
+        ;;
+   0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+        printprocesslog "WARN connection to DB failed"
+        ;;
+   *)   echo " check0=$check0 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 
+        printprocesslog "ERROR resettallruns.C failed for cacofiles"
+        ;;
 esac
 
+date=`date +%F`
 echo "checking missing cacofiles..." >> $scriptlog 2>&1 
+printprocesslog "INFO checking missing cacofiles"
 check1=`root -q -b $macrospath/findcacofiles.C+\("\"$date\""\,"\"$filesondisklogpath\""\) | tee $filesondisklogpath/findcacofiles-$datetime.log | grep int | sed -e 's/(int)//'`
 
 case $check1 in 
-   1)   echo "check1=$check1 -> everything ok -> missing cacofiles are found" >> $scriptlog 2>&1 ;;
-   *)   echo "check1=$check1 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 ;;
+   1)   echo " check1=$check1 -> everything ok -> missing cacofiles are found" >> $scriptlog 2>&1 
+        printprocesslog "INFO missing cacofiles found"
+        ;;
+   0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+        printprocesslog "WARN connection to DB failed"
+        ;;
+   *)   echo " check1=$check1 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
+        printprocesslog "ERROR findcacofiles.C failed"
+        ;;
 esac
 
+printprocesslog "INFO finding missing cacofiles"
 missingcacoruns=(`cat $filesondisklogpath/findcacofiles-$date.txt`)
 for missingcacorun in ${missingcacoruns[@]}
@@ -112,5 +130,5 @@
    echo "missing cacofile for run "$runno >> $scriptlog 2>&1 
    echo "-> finding cacofile" >> $scriptlog 2>&1 
-   ccfile=`find $subsystemdir/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep` 2>/dev/null
+   ccfile=`find $subsystempath/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep` 2>/dev/null
    echo " ccfile: "$ccfile  >> $scriptlog 2>&1 
    if [ "$ccfile" = "" ]
@@ -129,10 +147,18 @@
          continue
       else
+         printprocesslog "INFO inserting cacofile for run $missingcacorun"
          echo " inserting cacofile $file for run $missingcacorun..." >> $scriptlog 2>&1 
          check2=`root -q -b $macrospath/insertcacofile.C+\("\"$runno\""\,"\"$newrun\""\) | tee $filesondisklogpath/insertcacofile-$missingcacorun.log | grep int | sed -e 's/(int)//'`
 
          case $check2 in
-            1)   echo " check2=$check2 -> everything ok -> insert is done" >> $scriptlog 2>&1 ;;
-            *)   echo " check2=$check2 -> ERROR -> something went wrong while inserting run "$missingcacorun >> $scriptlog 2>&1 ;;
+            1)   echo " check2=$check2 -> everything ok -> insert is done" >> $scriptlog 2>&1 
+                 printprocesslog "INFO inserted $missingcacorun successfully"
+                 ;;
+            0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+                 printprocesslog "WARN connection to DB failed"
+                 ;;
+            *)   echo " check2=$check2 -> ERROR -> something went wrong while inserting run "$missingcacorun >> $scriptlog 2>&1 
+                 printprocesslog "ERROR insertcacofile.C failed for run $missingcacorun"
+                 ;;
          esac
          break
@@ -142,4 +168,5 @@
    then 
       echo " no cacofile found for run "$runno >> $scriptlog 2>&1 
+      printprocesslog "WARN no cacofile found for run $runno"
    else
       echo " cacofile: "$cacofile >> $scriptlog 2>&1 
@@ -149,7 +176,8 @@
 
 echo "checking disk for rawfiles..."  >> $scriptlog 2>&1 
+printprocesslog "INFO checking rawfiles"
 filename=$filesondisklogpath/rawfilesondisk-$datetime.txt
 column=fRawFileAvail
-find $datapath -name '*.raw' -o -name '*.gz' | cut -d_ -f2 > $filename
+find $datapath/rawfiles -name '*.raw' -o -name '*.gz' | cut -d_ -f2 > $filename
 
 echo "resetting runs..." >> $scriptlog 2>&1 
@@ -157,9 +185,15 @@
 
 case $check4 in 
-   1)   echo "check4=$check4 -> everything ok -> reset is done" >> $scriptlog 2>&1 ;;
-   *)   echo "check4=$check4 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 ;;
+   1)   echo " check4=$check4 -> everything ok -> reset is done" >> $scriptlog 2>&1 
+        printprocesslog "INFO rawfiles resetted successfully"
+        ;;
+   0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+        printprocesslog "WARN connection to DB failed"
+        ;;
+   *)   echo " check4=$check4 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 
+        printprocesslog "ERROR resettallruns.C failed for rawfiles"
+        ;;
 esac
 
 finish >> $scriptlog 2>&1
 
-
