Advertisement
Guest User

AtlasProbingFailedCheck2.sh

a guest
Nov 25th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.67 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. boinc_path="/home/luis/Applicazioni/boinc"
  4. lhc_project_url="https://lhcathome.cern.ch/lhcathome/"
  5. atlas_app_name="ATLAS"
  6. boinccmd="./boinccmd"
  7.  
  8. function isAtlasTask()
  9. {
  10.     init_data="$boinc_path/slots/$1/init_data.xml"
  11.     if [ -e "$init_data" ]; then
  12.         app_name=$(sed -n 's|[^<]*<app_name>\([^<]*\)</app_name>[^<]*|\1\n|gp' $init_data)
  13.         if [[ "$app_name" == "$atlas_app_name" ]]; then
  14.             return 1
  15.         else
  16.             return 0
  17.         fi
  18.     fi
  19.     return 0
  20. }
  21.  
  22. slot_dirs=( $(ls "$boinc_path/slots"))
  23. ndirs=${#slot_dirs[@]}
  24. for (( i = 0; i < ndirs; i++ )) do
  25.     isAtlasTask $i
  26.     if [ $? -eq 1 ]; then
  27.         stderr="$boinc_path/slots/$i/stderr.txt"
  28.         c=0 # cvmfs fails counter
  29.         j=0 # lines counter
  30.         jf=0 # cvmfs fail flag (used as line number too)
  31.         ljf=0 # previous cvmfs fail flag
  32.         while IFS= read -r line; do
  33.             if [[ "$line" == *"Probing /cvmfs/"*"... Failed!" ]]; then
  34.                 c=$((c+1))
  35.                 jf=$((j+1)) # Current line contains a fail
  36.                 ljf=$jf # Current line is the last line containing a fail
  37.             fi
  38.             if [ $jf -eq 0 -a $c -gt 0 ]; then # Current line doesn't contain a fail AND there were fails before
  39.                 echo "$c consecutive probing fails found in $stderr after line No. $ljf"
  40.                 if [ $c -ge 3 ]; then
  41.                     boinc_task_state="$boinc_path/slots/$i/boinc_task_state.xml"
  42.                     task_name=$(sed -n 's|[^<]*<result_name>\([^<]*\)</result_name>[^<]*|\1\n|gp' $boinc_task_state)
  43.                     cd $boinc_path && $boinccmd --task $lhc_project_url $task_name suspend #abort
  44.                     echo "$task_name suspended!" #aborted!"
  45.                 fi
  46.                 c=0 # Resetting cvmfs fails counter, all necessary actions taken
  47.             fi
  48.             j=$((j+1))
  49.             jf=0 # Resetting cvmfs fail flag for next line
  50.         done < "$stderr"
  51.     fi
  52. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement