source: trunk/DataCheck/Transfer/CheckTransfer.sh@ 17054

Last change on this file since 17054 was 16678, checked in by Daniela Dorner, 11 years ago
reworked output, added summary
  • Property svn:executable set to *
File size: 37.6 KB
Line 
1#!/bin/bash
2#
3# This script checks whether data can be deleted
4#
5
6source `dirname $0`/../Sourcefile.sh
7printprocesslog "INFO starting $0"
8
9logfile2=$logpath"/transfer/CheckTransfer.log"
10date > $logfile2 2>&1
11
12diskusage=( `ssh fact@161.72.93.131 "df -P /daq" | grep daq ` )
13# check if more than X GB are left on /daq
14if [ ${diskusage[3]} -lt 700000 ]
15then
16 printprocesslog "WARN less than 700 GB left on /daq "
17 echo "WARN less than 700 GB left on /daq "
18 echo "WARN less than 700 GB left on /daq " >> $logfile2 2>&1
19 sendemail="yes"
20fi
21
22diskusage2=( `df -P /scratch | grep scratch ` )
23# check if more than X GB are left on /scratch
24if [ ${diskusage2[3]} -lt 500000 ]
25then
26 printprocesslog "WARN less than 500 GB left on /scratch "
27 echo "WARN less than 500 GB left on /scratch "
28 echo "WARN less than 500 GB left on /scratch " >> $logfile2 2>&1
29 sendemail="yes"
30fi
31
32# needed for transfer to phido
33#source /home_nfs/isdc/fact_opr/myagent.sh
34
35# check first the disk in LP and on dl00
36ssh fact@161.72.93.131 "df -h /*da*"
37df -h /scratch
38echo ""
39echo "" >> $logfile2 2>&1
40
41# check next the DB to know if some transfer processes failed or crashed
42function check_runs_in_db()
43{
44 query="SELECT "$toquery" FROM "$1" "$where
45 #echo $query
46 runs=( `sendquery $query` )
47 if [ ${#runs[@]} -gt 0 ]
48 then
49 #for run in ${runs[@]}
50 #do
51 # echo $run
52 #done
53 sendemail="yes"
54 echo -e "\e[1;31m\x1b[5m ==>\e[00m "$1": "${runs[@]}"\e[1;31m\x1b[5m <==\e[00m "
55 echo "SELECT fNight, fRunId, fStartTime, fStopTime, fReturnCode FROM "$1" "$where";"
56 echo "UPDATE "$1" SET fStartTime=NULL, fStopTime=NULL, fAvailable=NULL, fReturnCode=NULL, fProcessingSiteKey=NULL "$where";"
57 echo -e " ==> "$1": "${runs[@]}" <== " >> $logfile2 2>&1
58 echo "---> Please check the DB and reset the processes if needed. " >> $logfile2 2>&1
59 echo "to check: SELECT fNight, fRunId, fStartTime, fStopTime, fReturnCode FROM "$1" "$where";" >> $logfile2 2>&1
60 echo "to reset: UPDATE "$1" SET fStartTime=NULL, fStopTime=NULL, fAvailable=NULL, fReturnCode=NULL, fProcessingSiteKey=NULL "$where";" >> $logfile2 2>&1
61 fi
62}
63# get information of runs where transfer had a problem
64toquery="fNight, fRunID, fStartTime, fStopTime, fAvailable, fProcessingSiteKey, fReturnCode "
65toquery="CONCAT(fNight, '_', fRunID, '(', fStartTime, '-', fStopTime, ':', fReturnCode, ')') "
66toquery="CONCAT(fNight, '_', fRunID, ':', fReturnCode) "
67toquery="IF (ISNULL(fReturnCode), CONCAT(fNight, '_', fRunID, 'crashed'), CONCAT(fNight, '_', fRunID, 'failed', fReturnCode)) "
68where="WHERE NOT ISNULL(fReturnCode) OR (NOT ISNULL(fStartTime) AND ISNULL(fStopTime)) AND fStartTime < DATE_ADD(Now(), INTERVAL -5 HOUR) "
69check_runs_in_db "RawFileRsyncedISDCStatus"
70check_runs_in_db "RawFileAvailWueStatus"
71# RawFileAvailISDC needs a different treatment
72# as return code 0 means that file is in fails folder in archive
73where="WHERE fReturnCode>0 OR (NOT ISNULL(fStartTime) AND ISNULL(fStopTime)) AND fStartTime < DATE_ADD(Now(), INTERVAL -1 HOUR) "
74check_runs_in_db "RawFileAvailISDCStatus"
75
76
77# get last 10 nights (skip current night)
78dates=( `date +%Y/%m/%d --date="-360hour"` `date +%Y/%m/%d --date="-336hour"` `date +%Y/%m/%d --date="-312hour"` \
79 `date +%Y/%m/%d --date="-288hour"` `date +%Y/%m/%d --date="-264hour"` `date +%Y/%m/%d --date="-240hour"` \
80 `date +%Y/%m/%d --date="-216hour"` `date +%Y/%m/%d --date="-192hour"` `date +%Y/%m/%d --date="-168hour"` \
81 `date +%Y/%m/%d --date="-144hour"` `date +%Y/%m/%d --date="-120hour"` `date +%Y/%m/%d --date="-96hour"` \
82 `date +%Y/%m/%d --date="-72hour"` `date +%Y/%m/%d --date="-48hour"` `date +%Y/%m/%d --date="-24hour"` \
83 )
84# get nights from directory in LP
85dates=( `ssh fact@161.72.93.131 "find /loc_data/zipraw -mindepth 3 -type d | sort | sed -e 's/\/loc_data\/zipraw\///g' "` )
86
87dates=( "2013/05/23" )
88#short="yes"
89
90numdaysok=0
91numdaysoklimit=5
92sumdata=0
93checklimit=5000
94for date in ${dates[@]}
95do
96 logfile=$logpath"/transfer/CheckTransfer_"`echo $date | sed -e 's/\//-/g'`".log"
97 #echo ""
98 #echo ""
99 #echo ""
100 #echo $date
101 #echo "" > $logfile 2>&1
102 #echo "" >> $logfile 2>&1
103 #echo "" >> $logfile 2>&1
104 echo $date > $logfile 2>&1
105
106 # some counters
107 numdiff=0
108 numok=0
109 numpb=0
110
111 # check always only $numdaysoklimit days
112 # and require at least $checklimit GB that have been checked
113 # remark: bc: expr1 < expr2: the result is 1 if expr1 is strictly less than expr2
114 if [ $numdaysok -ge $numdaysoklimit ] && [ $(echo " $sumdata > $checklimit " | bc -l) -eq 1 ]
115 then
116 printprocesslog "INFO more than "$numdaysoklimit" ok and more than "$checklimit" GB checked. "
117 continue
118 fi
119
120 # get paths
121 date2=`echo $date | sed -e 's/\///g'`
122# lprawpath="/daq/raw/"$date
123 lprawpath="/newdaq/raw/"$date
124# lprawpath2="/loc_data/raw/"$date
125 lprawpath2="/daq/raw/"$date
126 lpziprawpath="/loc_data/zipraw/"$date
127 localrawpath="/scratch/from_lapalma/raw/"$date
128 localrawpath3="/fact/raw/"$date
129# localfailpath="/archive/fact/fails/raw/"$date
130 localfailpath="/gpfs/fact/fact-archive/fails/raw/"$date
131 wuerawpath="/fact/raw/"$date
132 #phidorawpath="/fhgfs/groups/app/fact-construction/raw/"$date
133
134 # get disk usage and number of files for directory
135 newdaq=( `ssh fact@161.72.93.131 "if [ -d $lprawpath ]; then ls $lprawpath/* | wc -l; du -s -b --apparent-size $lprawpath; else echo '-1 -1 -1'; fi"` )
136 daq=( `ssh fact@161.72.93.131 "if [ -d $lprawpath2 ]; then ls $lprawpath2/* | wc -l; du -s -b --apparent-size $lprawpath2; else echo '-1 -1 -1'; fi"` )
137 if [ ${newdaq[0]} -eq -1 ] && [ ${daq[0]} -eq -1 ]
138 then
139 printprocesslog "INFO no data available on newdaq for "$date
140 echo "INFO no data available on newdaq for "$date >> $logfile 2>&1
141 continue
142 fi
143 zip=( `ssh fact@161.72.93.131 "if [ -d $lpziprawpath ]; then ls $lpziprawpath/* 2>/dev/null | wc -l; du -s -b --apparent-size $lpziprawpath; else echo '-1 -1 -1'; fi"` )
144 dl00=( `if [ -d $localrawpath ]; then ls $localrawpath/* | wc -l; du -s -b --apparent-size $localrawpath; else echo '-1 -1 -1'; fi` )
145 archive=( `if [ -d $localrawpath3 ]; then ls $localrawpath3/* 2>/dev/null | wc -l; du -L -s -b --apparent-size $localrawpath3; else echo '-1 -1 -1'; fi` )
146 fails=( `if [ -d $localfailpath ]; then ls $localfailpath/* | wc -l; du -L -s -b --apparent-size $localfailpath; else echo '-1 -1 -1'; fi` )
147 wue=( `ssh operator@coma.astro.uni-wuerzburg.de "if [ -d $wuerawpath ]; then ls $wuerawpath/* | wc -l; du -s -b --apparent-size $wuerawpath; else echo '-1 -1 -1'; fi"` )
148 #phido=( `ssh -i /home_nfs/isdc/fact_opr/.ssh/id_rsa.fact_opr.phido 129.217.160.201 "if [ -d $phidorawpath ]; then ls $phidorawpath/* | wc -l; du -s -b --apparent-size $phidorawpath; else echo '-1 -1 -1'; fi"` )
149 query="SELECT Sum(if(fHasDrsFile=1,2,1)) FROM RunInfo WHERE fNight="$date2
150 querystart="SELECT Sum(if(fHasDrsFile=1,2,1)) FROM "
151 queryjoin="LEFT JOIN RunInfo USING(fNight,fRunID) "
152 querywhere="WHERE fNight="$date2" AND NOT ISNULL(fStartTime) AND NOT ISNULL(fStopTime) AND ISNULL(fReturnCode)"
153 numruns=`sendquery`
154 if [ "$numruns" == "" ]
155 then
156 numruns=0
157 fi
158 query=$querystart"RawFileRsyncedISDCStatus "$queryjoin" "$querywhere
159 numrsynced=`sendquery`
160 if [ "$numrsynced" == "" ]
161 then
162 numrsynced=0
163 fi
164 query=$querystart"RawFileAvailISDCStatus "$queryjoin" "$querywhere
165 numisdc=`sendquery`
166 if [ "$numisdc" == "" ]
167 then
168 numisdc=0
169 fi
170 query=$querystart"RawFileAvailWueStatus "$queryjoin" "$querywhere
171 numwue=`sendquery`
172 if [ "$numwue" == "" ]
173 then
174 numwue=0
175 fi
176 #query=$querystart"RawFileAvailPhidoStatus "$queryjoin" "$querywhere
177 #numphido=`sendquery`
178 #if [ "$numphido" == "" ]
179 #then
180 # numphido=0
181 #fi
182
183 printprocesslog "disk: "
184 printprocesslog " newdaq "${newdaq[@]}
185 printprocesslog " daq "${daq[@]}
186 printprocesslog " data "${zip[@]}
187 printprocesslog " dl00 "${dl00[@]}
188 printprocesslog " wue "${wue[@]}
189 printprocesslog " arch "${archive[@]}
190 printprocesslog " fail "${fails[@]}
191 #printprocesslog " phido "${phido[@]}
192 printprocesslog "db: "
193 printprocesslog " runinfo "$numruns
194 printprocesslog " rsynced "$numrsynced
195 printprocesslog " isdc "$numisdc
196 printprocesslog " wue "$numwue
197 #printprocesslog " phido "$numphido
198 echo "disk: " >> $logfile 2>&1
199 echo " newdaq "${newdaq[@]} >> $logfile 2>&1
200 echo " daq "${daq[@]} >> $logfile 2>&1
201 echo " data "${zip[@]} >> $logfile 2>&1
202 echo " dl00 "${dl00[@]} >> $logfile 2>&1
203 echo " wue "${wue[@]} >> $logfile 2>&1
204 echo " arch "${archive[@]} >> $logfile 2>&1
205 echo " fail "${fails[@]} >> $logfile 2>&1
206 #echo " phido "${phido[@]} >> $logfile 2>&1
207 echo "db: " >> $logfile 2>&1
208 echo " runinfo "$numruns >> $logfile 2>&1
209 echo " rsynced "$numrsynced >> $logfile 2>&1
210 echo " isdc "$numisdc >> $logfile 2>&1
211 echo " wue "$numwue >> $logfile 2>&1
212 #echo " phido "$numphido >> $logfile 2>&1
213
214 # check if file are available in the different places
215 if [ ${dl00[0]} -eq -1 ] && [ $date2 -lt 20120308 ]
216 then
217 printprocesslog "INFO data not available on /scratch on dl00 for "$date
218 echo "INFO data not available on /scratch on dl00 for "$date >> $logfile 2>&1
219 fi
220 if [ ${archive[0]} -eq -1 ]
221 then
222 printprocesslog "INFO data not in archive for "$date
223 echo "INFO data not in archive for "$date >> $logfile 2>&1
224 fi
225
226 # check if number of files agree in the different places
227 # lp
228 if ! [ ${daq[0]} -eq -1 ] && ! [ ${daq[0]} -eq ${newdaq[0]} ]
229 then
230 printprocesslog "WARN number of files on daq (" ${daq[0]}") does not agree with number of files on newdaq (" ${newdaq[0]}") for "$date
231 echo "WARN number of files on daq (" ${daq[0]}") does not agree with number of files on newdaq (" ${newdaq[0]}") for "$date >> $logfile 2>&1
232 numpb=`echo " $numpb + 1 " | bc -l `
233 result1="1"
234 else
235 numok=`echo " $numok + 1 " | bc -l `
236 result1="0"
237 fi
238 # dl00
239 #if ! [ ${dl00[0]} -eq -1 ] && ! [ ${dl00[0]} -eq ${newdaq[0]} ]
240 if ! [ ${dl00[0]} -eq ${newdaq[0]} ]
241 then
242 printprocesslog "WARN number of files on dl00 (" ${dl00[0]}") does not agree with number of files in LP (" ${newdaq[0]}") for "$date
243 echo "WARN number of files on dl00 (" ${dl00[0]}") does not agree with number of files in LP (" ${newdaq[0]}") for "$date >> $logfile 2>&1
244 numpb=`echo " $numpb + 1 " | bc -l `
245 result1=$result1"1"
246 else
247 numok=`echo " $numok + 1 " | bc -l `
248 result1=$result1"0"
249 fi
250 # archive
251 if ! [ ${archive[0]} -eq -1 ] && ! [ ${archive[0]} -eq ${newdaq[0]} ]
252 then
253 printprocesslog "WARN number of files in archive (" ${archive[0]}") does not agree with number of files in LP (" ${newdaq[0]}") for "$date
254 echo "WARN number of files in archive (" ${archive[0]}") does not agree with number of files in LP (" ${newdaq[0]}") for "$date >> $logfile 2>&1
255 #check /archive/rev_1/failed
256 if ! [ ${fails[0]} -eq -1 ]
257 then
258 sum=`echo " ${fails[0]} + ${archive[0]} " | bc -l `
259 if ! [ $sum -eq ${newdaq[0]} ]
260 then
261 printprocesslog "ERROR number of files in whole archive ("$sum") is different from number of files in La Palma ("${newdaq[0]}")."
262 echo "ERROR number of files in whole archive ("$sum") is different from number of files in La Palma ("${newdaq[0]}")." >> $logfile 2>&1
263 numpb=`echo " $numpb + 1 " | bc -l `
264 result1=$result1"1"
265 else
266 numok=`echo " $numok + 1 " | bc -l `
267 result1=$result1"0"
268 fi
269 else
270 result1=$result1"1"
271 fi
272 else
273 if [ ${archive[0]} -eq -1 ]
274 then
275 numpb=`echo " $numpb + 1 " | bc -l `
276 result1=$result1"1"
277 else
278 numok=`echo " $numok + 1 " | bc -l `
279 result1=$result1"0"
280 fi
281 fi
282 # wue
283 #if ! [ ${wue[0]} -eq -1 ] && ! [ ${wue[0]} -eq ${newdaq[0]} ]
284 if ! [ ${wue[0]} -eq ${newdaq[0]} ]
285 then
286 printprocesslog "WARN number of files in Wue (" ${wue[0]}") does not agree with number of files in LP (" ${newdaq[0]}") for "$date
287 echo "WARN number of files in Wue (" ${wue[0]}") does not agree with number of files in LP (" ${newdaq[0]}") for "$date >> $logfile 2>&1
288 numpb=`echo " $numpb + 1 " | bc -l `
289 result1=$result1"1"
290 else
291 numok=`echo " $numok + 1 " | bc -l `
292 result1=$result1"0"
293 fi
294 ## phido
295 #if ! [ ${phido[0]} -eq -1 ] && ! [ ${phido[0]} -eq ${newdaq[0]} ]
296 #then
297 # printprocesslog "WARN number of files on Phido (" ${phido[0]}") does not agree with number of files in LP (" ${newdaq[0]}") for "$date
298 # echo "WARN number of files on Phido (" ${phido[0]}") does not agree with number of files in LP (" ${newdaq[0]}") for "$date >> $logfile 2>&1
299 # numpb=`echo " $numpb + 1 " | bc -l `
300 # result1=$result1"1"
301 #else
302 # numok=`echo " $numok + 1 " | bc -l `
303 # result1=$result1"0"
304 #fi
305
306 if [ "$short" = "yes" ] || [ "$result1" != "0000" ]
307 then
308 printprocesslog "number of files does not yet agree in all sites ("$result1") -> do no further checking."
309 echo "number of files does not yet agree in all sites ("$result1") -> do no further checking." >> $logfile 2>&1
310 echo ""
311 echo "SUMMARY for "$date
312 echo "-----------------------"
313 echo " number of files does not yet agree in all sites: "${newdaq[0]}" (newdaq) "${daq[0]}" (daq) "${zip[0]}" (data) "${dl00[0]}" (dl) "${wue[0]}" (wue) "${archive[0]}" (arch) "${fails[0]}" (fails) "
314 echo " "$date" is not yet transfered completely. For more details, please check the logfile "$logfile
315 echo "" >> $logfile 2>&1
316 echo "SUMMARY for "$date >> $logfile 2>&1
317 echo "-----------------------" >> $logfile 2>&1
318 echo " number of files does not yet agree in all sites: "${newdaq[0]}" (newdaq) "${daq[0]}" (daq) "${zip[0]}" (data) "${dl00[0]}" (dl) "${wue[0]}" (wue) "${archive[0]}" (arch) "${fails[0]}" (fails) " >> $logfile 2>&1
319 echo " "$date" is not yet transfered completely. For more details, please check the logfile "$logfile >> $logfile 2>&1
320 echo "" >> $logfile2 2>&1
321 echo "SUMMARY for "$date >> $logfile2 2>&1
322 echo "-----------------------" >> $logfile2 2>&1
323 echo " number of files does not yet agree in all sites: "${newdaq[0]}" (newdaq) "${daq[0]}" (daq) "${zip[0]}" (data) "${dl00[0]}" (dl) "${wue[0]}" (wue) "${archive[0]}" (arch) "${fails[0]}" (fails) " >> $logfile2 2>&1
324 echo " "$date" is not yet transfered completely. For more details, please check the logfile "$logfile >> $logfile2 2>&1
325 #echo "number of files does not yet agree in all sites ("$result1") -> do no further checking. "
326 #echo "disk: "
327 #echo " newdaq "${newdaq[@]}
328 #echo " daq "${daq[@]}
329 #echo " data "${zip[@]}
330 #echo " dl00 "${dl00[@]}
331 #echo " wue "${wue[@]}
332 #echo " arch "${archive[@]}
333 #echo " fail "${fails[@]}
334 ##echo " phido "${phido[@]}
335 #echo "db: "
336 #echo " runinfo "$numruns
337 #echo " rsynced "$numrsynced
338 #echo " isdc "$numisdc
339 #echo " wue "$numwue
340 ##echo " phido "$numphido
341 continue
342 fi
343
344 #result=$result"-"
345 # check du for raw files
346 # la palma
347 if ! [ ${newdaq[1]} -eq ${daq[1]} ]
348 then
349 printprocesslog "WARN size of data doesn't agree on newdaq ("${newdaq[1]}") and daq ("${daq[1]}") for "$date
350 echo "WARN size of data doesn't agree on newdaq ("${newdaq[1]}") and daq ("${daq[1]}") for "$date >> $logfile 2>&1
351 numdiff=`echo " $numdiff + 1 " | bc -l `
352 numpb=`echo " $numpb + 1 " | bc -l `
353 result2="1"
354 else
355 numok=`echo " $numok + 1 " | bc -l `
356 result2="0"
357 fi
358 # check du for zipped raw files
359 # dl00
360 if ! [ ${zip[1]} -eq ${dl00[1]} ] && [ $date2 -gt 20120307 ]
361 then
362 printprocesslog "WARN size of data doesn't agree on data ("${zip[1]}") and dl00 ("${dl00[1]}") for "$date
363 echo "WARN size of data doesn't agree on data ("${zip[1]}") and dl00 ("${dl00[1]}") for "$date >> $logfile 2>&1
364 if ! [ ${dl00[1]} -eq -1 ]
365 then
366 numdiff=`echo " $numdiff + 1 " | bc -l `
367 numpb=`echo " $numpb + 1 " | bc -l `
368 result2=$result2"1"
369 else
370 numok=`echo " $numok + 1 " | bc -l `
371 result2=$result2"0"
372 fi
373 else
374 numok=`echo " $numok + 1 " | bc -l `
375 result2=$result2"0"
376 fi
377 # archive
378 if ! [ ${zip[1]} -eq ${archive[1]} ]
379 then
380 printprocesslog "WARN size of data doesn't agree on data ("${zip[1]}") and in archive ("${archive[1]}") for "$date
381 echo "WARN size of data doesn't agree on data ("${zip[1]}") and in archive ("${archive[1]}") for "$date >> $logfile 2>&1
382 if ! [ ${archive[1]} -eq -1 ]
383 then
384 numdiff=`echo " $numdiff + 1 " | bc -l `
385 numpb=`echo " $numpb + 1 " | bc -l `
386 result2=$result2"1"
387 else
388 numok=`echo " $numok + 1 " | bc -l `
389 result2=$result2"0"
390 fi
391 else
392 numok=`echo " $numok + 1 " | bc -l `
393 result2=$result2"0"
394 fi
395 # wue
396 if ! [ ${zip[1]} -eq ${wue[1]} ]
397 then
398 printprocesslog "WARN size of data doesn't agree on data ("${zip[1]}") and in Wue ("${wue[1]}") for "$date
399 echo "WARN size of data doesn't agree on data ("${zip[1]}") and in Wue ("${wue[1]}") for "$date >> $logfile 2>&1
400 if ! [ ${wue[1]} -eq -1 ]
401 then
402 numdiff=`echo " $numdiff + 1 " | bc -l `
403 numpb=`echo " $numpb + 1 " | bc -l `
404 result2=$result2"1"
405 else
406 numok=`echo " $numok + 1 " | bc -l `
407 result2=$result2"0"
408 fi
409 else
410 numok=`echo " $numok + 1 " | bc -l `
411 result2=$result2"0"
412 fi
413 ## phido
414 #if ! [ ${zip[1]} -eq ${phido[1]} ]
415 #then
416 # printprocesslog "WARN size of data doesn't agree on data ("${zip[1]}") and on Phido ("${phido[1]}") for "$date
417 # echo "WARN size of data doesn't agree on data ("${zip[1]}") and on Phido ("${phido[1]}") for "$date >> $logfile 2>&1
418 # if ! [ ${phido[1]} -eq -1 ]
419 # then
420 # numdiff=`echo " $numdiff + 1 " | bc -l `
421 # numpb=`echo " $numpb + 1 " | bc -l `
422 # result2=$result2"1"
423 # else
424 # numok=`echo " $numok + 1 " | bc -l `
425 # result2=$result2"0"
426 # fi
427 #else
428 # numok=`echo " $numok + 1 " | bc -l `
429 # result2=$result2"0"
430 #fi
431 #result=$result"-"
432
433 # check DB (only starting from 8.3.2012) (if-clause to be removed later)
434 if [ $date2 -gt 20120307 ]
435 then
436 # lp
437 if ! [ $numruns -eq ${newdaq[0]} ]
438 then
439 printprocesslog "WARN number of runs on newdaq ("${newdaq[0]}") not equal to number of runs ("$numruns")"
440 echo "WARN number of runs on newdaq ("${newdaq[0]}") not equal to number of runs ("$numruns")" >> $logfile 2>&1
441 numpb=`echo " $numpb + 1 " | bc -l `
442 result3="1"
443 else
444 numok=`echo " $numok + 1 " | bc -l `
445 result3="0"
446 fi
447 # dl00
448 if ! [ $numruns -eq $numrsynced ]
449 then
450 printprocesslog "WARN number of rsynced runs ("$numrsynced") not equal to number of runs ("$numruns")"
451 echo "WARN number of rsynced runs ("$numrsynced") not equal to number of runs ("$numruns")" >> $logfile 2>&1
452 numpb=`echo " $numpb + 1 " | bc -l `
453 result3=$result3"1"
454 else
455 numok=`echo " $numok + 1 " | bc -l `
456 result3=$result3"0"
457 fi
458 # archive
459 if ! [ $numruns -eq $numisdc ]
460 then
461 printprocesslog "WARN number of ingested files in archive ("$numisdc") not equal to number of runs ("$numruns")"
462 echo "WARN number of ingested files in archive ("$numisdc") not equal to number of runs ("$numruns")" >> $logfile 2>&1
463 numpb=`echo " $numpb + 1 " | bc -l `
464 result3=$result3"1"
465 else
466 numok=`echo " $numok + 1 " | bc -l `
467 result3=$result3"0"
468 fi
469 # wue
470 if ! [ $numruns -eq $numwue ]
471 then
472 printprocesslog "WARN number of backuped in Wue ("$numrsynced") not equal to number of runs ("$numruns")"
473 echo "WARN number of backuped in Wue ("$numrsynced") not equal to number of runs ("$numruns")" >> $logfile 2>&1
474 numpb=`echo " $numpb + 1 " | bc -l `
475 result3=$result3"1"
476 else
477 numok=`echo " $numok + 1 " | bc -l `
478 result3=$result3"0"
479 fi
480 ## phido
481 #if ! [ $numruns -eq $numphido ]
482 #then
483 # printprocesslog "WARN number of backuped on Phido ("$numrsynced") not equal to number of runs ("$numruns")"
484 # echo "WARN number of backuped on Phido ("$numrsynced") not equal to number of runs ("$numruns")" >> $logfile 2>&1
485 # numpb=`echo " $numpb + 1 " | bc -l `
486 # result3=$result3"1"
487 #else
488 # numok=`echo " $numok + 1 " | bc -l `
489 # result3=$result3"0"
490 #fi
491 fi
492
493 #numdiff=0 # add for debugging so that single file sizes are not checked
494 printprocesslog "numdiff: "$numdiff
495 printprocesslog "INFO numok: "$numok
496 printprocesslog "INFO numpb: "$numpb
497 echo "numdiff: "$numdiff >> $logfile 2>&1
498 echo "INFO numok: "$numok >> $logfile 2>&1
499 echo "INFO numpb: "$numpb >> $logfile 2>&1
500 #if [ $numdiff -gt 0 ]
501 if [ $numdiff -ge 0 ]
502 then
503 query="SELECT fRunID FROM RunInfo WHERE fNight="$date2
504 runs=( `sendquery` )
505 archivediffcounter=0
506 archiveokcounter=0
507 wuediffcounter=0
508 wueokcounter=0
509 #phidodiffcounter=0
510 #phidookcounter=0
511 dl00diffcounter=0
512 dl00okcounter=0
513 daqdiffcounter=0
514 daqokcounter=0
515 printprocesslog "INFO found "${#runs[@]}" rawfiles in DB."
516 echo "INFO found "${#runs[@]}" rawfiles in DB." >> $logfile 2>&1
517 for run in ${runs[@]}
518 do
519 rawfile=$date2"_"`printf %03d $run`".fits"
520 rawfile2=$rawfile".gz"
521
522 # get file sizes for run
523 sizenewdaq=( `ssh fact@161.72.93.131 "ls -l ${lprawpath}/${rawfile} 2>/dev/null | awk '{ print \\\$5 }'"` )
524 sizedaq=( `ssh fact@161.72.93.131 "ls -l $lprawpath2/$rawfile 2>/dev/null | awk '{ print \\\$5 }'"` )
525 sizezip=( `ssh fact@161.72.93.131 "ls -l $lpziprawpath/$rawfile2 2>/dev/null | awk '{ print \\\$5 }'"` )
526 if ! [ ${dl00[1]} -eq -1 ]
527 then
528 sizedl00=( `ls -l $localrawpath/$rawfile2 2>/dev/null | awk '{ print \$5 }'` )
529 fi
530 if ! [ ${archive[1]} -eq -1 ]
531 then
532 sizearchive=( `ls -lH $localrawpath3/$rawfile2 2>/dev/null | awk '{ print \$5 }'` )
533 fi
534 if ! [ ${fails[1]} -eq -1 ]
535 then
536 sizefails=( `ls -lH $localfailpath/$rawfile2 2>/dev/null | awk '{ print \$5 }'` )
537 fi
538 if ! [ ${wue[1]} -eq -1 ]
539 then
540 sizewue=( `ssh operator@coma.astro.uni-wuerzburg.de "ls -l $wuerawpath/$rawfile2 2>/dev/null | awk '{ print \\\$5 }'"` )
541 fi
542 #if ! [ ${phido[1]} -eq -1 ]
543 #then
544 # sizephido=( `ssh -i /home_nfs/isdc/fact_opr/.ssh/id_rsa.fact_opr.phido 129.217.160.201 "ls -l $phidorawpath/$rawfile2 2>/dev/null | awk '{ print \\\$5 }'"` )
545 #fi
546
547 # check file sizes for run
548 # lp
549 if ! [ "$sizenewdaq" = "$sizedaq" ]
550 then
551 printprocesslog " "$rawfile" newdaq("$sizenewdaq") daq("$sizedaq")"
552 echo " "$rawfile" newdaq("$sizenewdaq") daq("$sizedaq")" >> $logfile 2>&1
553 daqdiffcounter=`echo " $daqdiffcounter + 1 " | bc -l `
554 else
555 daqokcounter=`echo " $daqokcounter + 1 " | bc -l `
556 fi
557 # dl00
558 if ! [ "$sizezip" = "$sizedl00" ] && ! [ ${dl00[1]} -eq -1 ]
559 then
560 printprocesslog " "$rawfile2" data("$sizezip") dl00("$sizedl00")"
561 echo " "$rawfile2" data("$sizezip") dl00("$sizedl00")" >> $logfile 2>&1
562 dl00diffcounter=`echo " $dl00diffcounter + 1 " | bc -l `
563 else
564 dl00okcounter=`echo " $dl00okcounter + 1 " | bc -l `
565 fi
566 # archive
567 #if [ "$sizezip" != "$sizearchive" -a ${archive[1]} -ne -1 -a "$sizearchive" != "" ] || [ "$sizezip" != "$sizefails" -a ${fails[1]} -ne -1 -a "$sizefails" != "" ] #not yet ingested files are treated wrongly
568 #if [ ${archive[1]} -ne -1 ] && [ "$sizezip" != "$sizearchive" -o "$sizezip" != "$sizefails" ]
569 if [ ${archive[1]} -ne -1 -a "$sizezip" != "$sizearchive" -a "$sizezip" != "$sizefails" ]
570 then
571 printprocesslog " "$rawfile2" data("$sizezip") archive("$sizearchive"/"$sizefails")"
572 echo " "$rawfile2" data("$sizezip") archive("$sizearchive"/"$sizefails")" >> $logfile 2>&1
573 #echo " "$sizezip"-"$sizearchive"-"${archive[1]}"-"$sizezip"-"$sizefails"-"${fails[1]}
574 archivediffcounter=`echo " $archivediffcounter + 1 " | bc -l `
575 else
576 archiveokcounter=`echo " $archiveokcounter + 1 " | bc -l `
577 fi
578 # wue
579 if ! [ "$sizezip" = "$sizewue" ] && ! [ ${wue[1]} -eq -1 ]
580 then
581 printprocesslog " "$rawfile2" data("$sizezip") wue("$sizewue")"
582 echo " "$rawfile2" data("$sizezip") wue("$sizewue")" >> $logfile 2>&1
583 wuediffcounter=`echo " $wuediffcounter + 1 " | bc -l `
584 else
585 wueokcounter=`echo " $wueokcounter + 1 " | bc -l `
586 fi
587 ## phido
588 #if ! [ "$sizezip" = "$sizephido" ] && ! [ ${phido[1]} -eq -1 ]
589 #then
590 # printprocesslog " "$rawfile2" data("$sizezip") phido("$sizephido")"
591 # echo " "$rawfile2" data("$sizezip") phido("$sizephido")" >> $logfile 2>&1
592 # phidodiffcounter=`echo " $phidodiffcounter + 1 " | bc -l `
593 #else
594 # phidookcounter=`echo " $phidookcounter + 1 " | bc -l `
595 #fi
596 done
597 query="SELECT fRunID FROM RunInfo WHERE fNight="$date2" AND fHasDrsFile=1"
598 drsruns=( `sendquery` )
599 printprocesslog "INFO found "${#drsruns[@]}" drsfiles in DB."
600 echo "INFO found "${#drsruns[@]}" drsfiles in DB." >> $logfile 2>&1
601 for drsrun in ${drsruns[@]}
602 do
603 rawfile=$date2"_"`printf %03d $drsrun`".drs.fits"
604 rawfile2=$rawfile".gz"
605 # get file sizes for run
606 sizenewdaq=( `ssh fact@161.72.93.131 "ls -l ${lprawpath}/${rawfile} 2>/dev/null | awk '{ print \\\$5 }'"` )
607 sizedaq=( `ssh fact@161.72.93.131 "ls -l $lprawpath2/$rawfile 2>/dev/null | awk '{ print \\\$5 }'"` )
608 sizezip=( `ssh fact@161.72.93.131 "ls -l $lpziprawpath/$rawfile2 2>/dev/null | awk '{ print \\\$5 }'"` )
609 if ! [ ${dl00[1]} -eq -1 ]
610 then
611 sizedl00=( `ls -l $localrawpath/$rawfile2 2>/dev/null | awk '{ print \$5 }'` )
612 fi
613 if ! [ ${archive[1]} -eq -1 ]
614 then
615 sizearchive=( `ls -l $localrawpath3/$rawfile2 2>/dev/null | awk '{ print \$5 }'` )
616 fi
617 if ! [ ${fails[1]} -eq -1 ]
618 then
619 sizefails=( `ls -l $localfailpath/$rawfile2 2>/dev/null | awk '{ print \$5 }'` )
620 fi
621 if ! [ ${wue[1]} -eq -1 ]
622 then
623 sizewue=( `ssh operator@coma.astro.uni-wuerzburg.de "ls -l $wuerawpath/$rawfile2 2>/dev/null | awk '{ print \\\$5 }'"` )
624 fi
625 #if ! [ ${phido[1]} -eq -1 ]
626 #then
627 # sizephido=( `ssh -i /home_nfs/isdc/fact_opr/.ssh/id_rsa.fact_opr.phido 129.217.160.201 "ls -l $phidorawpath/$rawfile2 2>/dev/null | awk '{ print \\\$5 }'"` )
628 #fi
629
630 # check file sizes for run
631 # lp
632 if ! [ "$sizenewdaq" = "$sizedaq" ]
633 then
634 printprocesslog " "$rawfile" newdaq("$sizenewdaq") daq("$sizedaq")"
635 echo " "$rawfile" newdaq("$sizenewdaq") daq("$sizedaq")" >> $logfile 2>&1
636 daqdiffcounter=`echo " $daqdiffcounter + 1 " | bc -l `
637 else
638 daqokcounter=`echo " $daqokcounter + 1 " | bc -l `
639 fi
640 # dl00
641 if ! [ "$sizezip" = "$sizedl00" ] && ! [ ${dl00[1]} -eq -1 ]
642 then
643 printprocesslog " "$rawfile2" data("$sizezip") dl00("$sizedl00")"
644 echo " "$rawfile2" data("$sizezip") dl00("$sizedl00")" >> $logfile 2>&1
645 dl00diffcounter=`echo " $dl00diffcounter + 1 " | bc -l `
646 else
647 dl00okcounter=`echo " $dl00okcounter + 1 " | bc -l `
648 fi
649 #if [ "$sizezip" != "$sizearchive" -a ${archive[1]} -ne -1 ] || [ "$sizezip" != "$sizefails" -a ${fails[1]} -ne -1 ]
650 if [ "$sizezip" != "$sizearchive" -a ${archive[1]} -ne -1 -a "$sizearchive" != "" ] || [ "$sizezip" != "$sizefails" -a ${fails[1]} -ne -1 -a "$sizefails" != "" ]
651 then
652 printprocesslog " "$rawfile2" data("$sizezip") archive("$sizearchive"/"$sizefails")"
653 echo " "$rawfile2" data("$sizezip") archive("$sizearchive"/"$sizefails")" >> $logfile 2>&1
654 archivediffcounter=`echo " $archivediffcounter + 1 " | bc -l `
655 else
656 archiveokcounter=`echo " $archiveokcounter + 1 " | bc -l `
657 fi
658 # wue
659 if ! [ "$sizezip" = "$sizewue" ] && ! [ ${wue[1]} -eq -1 ]
660 then
661 printprocesslog " "$rawfile2" data("$sizezip") wue("$sizewue")"
662 echo " "$rawfile2" data("$sizezip") wue("$sizewue")" >> $logfile 2>&1
663 wuediffcounter=`echo " $wuediffcounter + 1 " | bc -l `
664 else
665 wueokcounter=`echo " $wueokcounter + 1 " | bc -l `
666 fi
667 ## phido
668 #if ! [ "$sizezip" = "$sizephido" ] && ! [ ${phido[1]} -eq -1 ]
669 #then
670 # printprocesslog " "$rawfile2" data("$sizezip") phido("$sizephido")"
671 # echo " "$rawfile2" data("$sizezip") phido("$sizephido")" >> $logfile 2>&1
672 # phidodiffcounter=`echo " $phidodiffcounter + 1 " | bc -l `
673 #else
674 # phidookcounter=`echo " $phidookcounter + 1 " | bc -l `
675 #fi
676 done
677
678 #result=$result"-"
679 # raw files
680 if [ $daqokcounter -eq ${daq[0]} ]
681 then
682 numok=`echo " $numok + 1 " | bc -l `
683 result4="0"
684 else
685 result4="1"
686 numpb=`echo " $numpb + 1 " | bc -l `
687 fi
688 # zipped files
689 # dl00
690 if [ $dl00okcounter -eq ${dl00[0]} ]
691 then
692 result4=$result4"0"
693 numok=`echo " $numok + 1 " | bc -l `
694 else
695 result4=$result4"1"
696 numpb=`echo " $numpb + 1 " | bc -l `
697 fi
698 # archive
699 # daq had been used, because archive[0] doesn't include fails[0]
700 #if [ $archiveokcounter -eq ${newdaq[0]} ]
701 # archive[0] had been used, because newdaq[0] might be empty
702 # in case the data was taken on data
703 #if [ $archiveokcounter -eq ${archive[0]} ]
704 # compare with daq[0] as there should be always data on data
705 if [ $archiveokcounter -eq ${daq[0]} ]
706 then
707 result4=$result4"0"
708 numok=`echo " $numok + 1 " | bc -l `
709 else
710 result4=$result4"1"
711 numpb=`echo " $numpb + 1 " | bc -l `
712 fi
713 # wue
714 if [ $wueokcounter -eq ${wue[0]} ]
715 then
716 result4=$result4"0"
717 numok=`echo " $numok + 1 " | bc -l `
718 else
719 result4=$result4"1"
720 numpb=`echo " $numpb + 1 " | bc -l `
721 fi
722 ## phido
723 #if [ $phidookcounter -eq ${phido[0]} ]
724 #then
725 # result4=$result4"0"
726 # numok=`echo " $numok + 1 " | bc -l `
727 #else
728 # result4=$result4"1"
729 # numpb=`echo " $numpb + 1 " | bc -l `
730 #fi
731 printprocesslog "INFO "$daqokcounter" files are ok on daq (raw)."
732 printprocesslog "INFO "$dl00okcounter" files are ok on dl00."
733 printprocesslog "INFO "$wueokcounter" files are ok in Wue."
734 printprocesslog "INFO "$archiveokcounter" files are ok in the archive."
735 #printprocesslog "INFO "$phidookcounter" files are ok on Phido."
736 printprocesslog "WARN "$daqdiffcounter" files have a different size on daq (raw)."
737 printprocesslog "WARN "$dl00diffcounter" files have a different size on dl00."
738 printprocesslog "WARN "$wuediffcounter" files have a different size in Wue."
739 printprocesslog "WARN "$archivediffcounter" files have a different size in the archive."
740 #printprocesslog "WARN "$phidodiffcounter" files have a different size on Phido."
741 echo "INFO "$daqokcounter" files are ok on daq (raw)." >> $logfile 2>&1
742 echo "INFO "$dl00okcounter" files are ok on dl00." >> $logfile 2>&1
743 echo "INFO "$wueokcounter" files are ok in Wue." >> $logfile 2>&1
744 echo "INFO "$archiveokcounter" files are ok in the archive." >> $logfile 2>&1
745 #echo "INFO "$phidookcounter" files are ok on Phido." >> $logfile 2>&1
746 echo "WARN "$daqdiffcounter" files have a different size on daq (raw)." >> $logfile 2>&1
747 echo "WARN "$dl00diffcounter" files have a different size on dl00." >> $logfile 2>&1
748 echo "WARN "$wuediffcounter" files have a different size in Wue." >> $logfile 2>&1
749 echo "WARN "$archivediffcounter" files have a different size in the archive." >> $logfile 2>&1
750 #echo "WARN "$phidodiffcounter" files have a different size on Phido." >> $logfile 2>&1
751 fi
752
753 # print summary:
754 printprocesslog "INFO day ok: "$numdaysok
755 printprocesslog "INFO numok: "$numok
756 printprocesslog "INFO numpb: "$numpb
757 printprocesslog "result:"
758 printprocesslog "(#files-dudir-db-filesize)"
759 #printprocesslog " ldawp-ldawp-ldawp-ldawp"
760 printprocesslog " ldaw-ldaw-ldaw-ldaw"
761 printprocesslog " "$result1"-"$result2"-"$result3"-"$result4
762 echo "INFO day ok: "$numdaysok >> $logfile 2>&1
763 echo "INFO numok: "$numok >> $logfile 2>&1
764 echo "INFO numpb: "$numpb >> $logfile 2>&1
765 echo "result:" >> $logfile 2>&1
766 echo "(#files-dudir-db-filesize)" >> $logfile 2>&1
767 #echo " ldawp-ldawp-ldawp-ldawp" >> $logfile 2>&1
768 echo " ldaw-ldaw-ldaw-ldaw" >> $logfile 2>&1
769 echo " "$result1"-"$result2"-"$result3"-"$result4 >> $logfile 2>&1
770 sumdatanew=`echo " ( ${daq[1]} + ${zip[1]} ) / 1024 / 1024 / 1024 " | bc -l | cut -d. -f1`
771 sumdata=`echo " $sumdata + $sumdatanew " | bc -l | cut -d. -f1`
772 printprocesslog "checked alread "$sumdata" GB. "$sumdatanew" "${daq[1]}" "${zip[1]}
773 if [ $numpb -lt 4 ]
774 then
775 numdaysok=`echo " $numdaysok + 1 " | bc -l `
776 fi
777
778 echo "SUMMARY for "$date
779 echo "-----------------------"
780 echo "" >> $logfile 2>&1
781 echo "SUMMARY for "$date >> $logfile 2>&1
782 echo "-----------------------" >> $logfile 2>&1
783 echo "" >> $logfile2 2>&1
784 echo "SUMMARY for "$date >> $logfile2 2>&1
785 echo "-----------------------" >> $logfile2 2>&1
786 #echo "res1:"$result1
787 #echo "res3:"$result3
788 #echo "res4:"$result4
789 #echo "arch:"${archive[0]}
790 #echo "isdc:"$numisdc
791 if [ "$result1" = "0000" ] && [ "$result3" = "0000" ] && [ "$result4" = "0000" ]
792 then
793 echo " EVERYTHING is ok. "$date" can be deleted. "
794 echo " EVERYTHING is ok. "$date" can be deleted. " >> $logfile 2>&1
795 echo " EVERYTHING is ok. "$date" can be deleted. " >> $logfile2 2>&1
796 echo " Details in the logfile "$logfile
797 echo " Details in the logfile "$logfile >> $logfile 2>&1
798 echo " Details in the logfile "$logfile >> $logfile2 2>&1
799 else
800 if [ "$result1" = "0000" ] && [ "$result3" = "0010" ] && [ "$result4" = "0000" ] && [ ${archive[0]} -eq $numisdc ]
801 then
802 echo " "${fails[0]}" file(s) corrupt (fails folder), but files are transfered correctly. "
803 echo " "${fails[0]}" file(s) corrupt (fails folder), but files are transfered correctly. " >> $logfile 2>&1
804 echo " "${fails[0]}" file(s) corrupt (fails folder), but files are transfered correctly. " >> $logfile2 2>&1
805 echo " TRANSFER is ok. "$date" can be deleted. "
806 echo " TRANSFER is ok. "$date" can be deleted. " >> $logfile 2>&1
807 echo " TRANSFER is ok. "$date" can be deleted. " >> $logfile2 2>&1
808 echo " Details in the logfile "$logfile
809 echo " Details in the logfile "$logfile >> $logfile 2>&1
810 echo " Details in the logfile "$logfile >> $logfile2 2>&1
811 else
812 echo " "$date" is not yet transfered completely. Please check the logfile "$logfile
813 echo " "$date" is not yet transfered completely. Please check the logfile "$logfile >> $logfile 2>&1
814 echo " "$date" is not yet transfered completely. Please check the logfile "$logfile >> $logfile2 2>&1
815 echo " resetting jobs in the DB might be needed."
816 echo " resetting jobs in the DB might be needed." >> $logfile 2>&1
817 echo " resetting jobs in the DB might be needed." >> $logfile2 2>&1
818 fi
819 fi
820 if [ $daqdiffcounter -gt 0 ]
821 then
822 echo " WARN "$daqdiffcounter" files have a different size on daq (raw)."
823 echo " WARN "$daqdiffcounter" files have a different size on daq (raw)." >> $logfile 2>&1
824 echo " WARN "$daqdiffcounter" files have a different size on daq (raw)." >> $logfile2 2>&1
825 fi
826 if [ $dl00diffcounter -gt 0 ]
827 then
828 echo " WARN "$dl00diffcounter" files have a different size on dl00."
829 echo " WARN "$dl00diffcounter" files have a different size on dl00." >> $logfile 2>&1
830 echo " WARN "$dl00diffcounter" files have a different size on dl00." >> $logfile2 2>&1
831 fi
832 if [ $wuediffcounter -gt 0 ]
833 then
834 echo " WARN "$wuediffcounter" files have a different size in Wue."
835 echo " WARN "$wuediffcounter" files have a different size in Wue." >> $logfile 2>&1
836 echo " WARN "$wuediffcounter" files have a different size in Wue." >> $logfile2 2>&1
837 fi
838 if [ $archivediffcounter -gt 0 ]
839 then
840 echo " WARN "$archivediffcounter" files have a different size in the archive."
841 echo " WARN "$archivediffcounter" files have a different size in the archive." >> $logfile 2>&1
842 echo " WARN "$archivediffcounter" files have a different size in the archive." >> $logfile2 2>&1
843 fi
844done
845
846#sendemail="yes"
847if [ "$sendemail" = "yes" ]
848then
849 echo "INFO send email with "$logfile2"to shift@fact-project.org "
850 printprocesslog "INFO send email with "$logfile2"to shift@fact-project.org "
851 cat $logfile2 | mail -s "testmail for info on deleting data" shift@fact-project.org
852fi
853
854printprocesslog "INFO finished $0"
855
Note: See TracBrowser for help on using the repository browser.