Changeset 19499
- Timestamp:
- 04/29/19 12:10:26 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataCheck/Monitoring/CheckSwiftSchedule.sh
r19469 r19499 37 37 38 38 39 function getschedule() 40 { 41 text=`links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$1 | grep $1'\|was not found' >> $schedulefile ` 42 #text=`links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$1 | grep $1 >> $schedulefile ` 43 check1=$? 44 #echo "check "$check1 45 if [ "$text" != "" ] || [ $check1 -gt 0 ] 46 then 47 printprocesslog "links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d="$1" | grep "$1" >> "$schedulefile 48 printprocesslog "WARN could not get Swift schedule ("$text", return code: "$check1")" 49 echo "WARN could not get Swift schedule ("$text", return code: "$check1")" 50 if [ "$text" = "Connection timed out" ] 51 then 52 printprocesslog "WARN could not connect to https://www.swift.psu.edu/operations/obsSchedule.php?d="$1 53 finish 54 fi 55 fi 56 } 57 39 58 40 59 for date in ${dates[@]} … … 53 72 schedulefile=$schedulepath/swift.schedule 54 73 schedulefile2=$schedulepath/swift.schedule.formated 74 schedulefile2old=$schedulepath/swift.schedule.formated.old 55 75 schedulefile3=$schedulepath/swift.schedule.txt 56 76 schedulefile4=$schedulepath/swift.schedule-cut.txt 57 77 58 78 # overwrite already existing file 59 echo " "> $schedulefile79 echo "Schedule retrieved at "`date` > $schedulefile 60 80 # Get Swift Data 61 81 # for the date of sunset 62 82 printprocesslog "INFO Checking "$date2 63 83 #lynx -width 200 -nolist -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$date2 | grep $date2 >> $schedulefile 64 links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$date2 | grep $date2 >> $schedulefile 84 #links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$date2 | grep $date2 >> $schedulefile 85 getschedule $date2 65 86 # for the date of sunrise 66 87 nextday=`date +%Y-%m-%d --date=$date2"+24hour"` 67 88 printprocesslog "INFO Checking "$nextday 68 89 #lynx -width 200 -nolist -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$nextday | grep $nextday >> $schedulefile 69 links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$nextday | grep $nextday >> $schedulefile70 # fixme: find out why sometimes second day is missing in file (probably just put online late)90 #links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$nextday | grep $nextday >> $schedulefile 91 getschedule $nextday 71 92 72 93 # check if schedule is empty 73 checkcontent=`cat $schedulefile` 74 if [ "$checkcontent" = "" ] 75 then 94 #checkcontent=`cat $schedulefile` 95 #if [ "$checkcontent" = "" ] 96 #then 97 # printprocesslog "INFO No Schedule found for the night of "$date 98 # continue 99 #fi 100 numnotfound=`grep -c 'was not found' $schedulefile` 101 if [ $numnotfound -gt 1 ] 102 then 76 103 printprocesslog "INFO No Schedule found for the night of "$date 104 #echo "INFO No Schedule found for the night of "$date 77 105 continue 78 106 fi 107 if [ $numnotfound -eq 1 ] 108 then 109 printprocesslog "INFO No Schedule found half of the night ("$date")" 110 #echo "INFO No Schedule found half of the night ("$date")" 111 fi 79 112 113 # copy of formatted schedulefile for comparison 114 if [ -e $schedulefile2 ] 115 then 116 mv $schedulefile2 $schedulefile2old 117 fi 80 118 # grep only the columns which are needed 81 119 #cat $schedulefile | sed -r -e 's/[0-9]{5,6}[\ ]{1,4}[0-9]{1,3}[\ ]{1,6}//' | grep -o -E '^[\ ]{1,20}20[1-9][0-9]-[01][0-9]-[0-3][0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \ \ 20[1-9][0-9]-[01][0-9]-[0-3][0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \ \ [A-Z1-4]([A-Za-z0-9][\ \.\+\-]?){3,20}' > $schedulefile2 82 120 cat $schedulefile | awk -v d1=$date2 -v d2=$nextday '{ if (($1 ~ d1 && $2 ~ /^18|^19|^20|^21|^22|^23/) || ( $1 ~ d2 && $2 ~ /^0/)) print $1" "$2" "$3" "$4" "$7" "$8" "$9}' | sed -r -e 's/[-]?[0-9]{1,3}[.][0-9]{5}$//' | sed -r -e 's/[-]?[0-9]{1,3}[.][0-9]{5}\ $//' > $schedulefile2 121 122 # check if there is an update in the schedule 123 # return values of diff 124 # 0: no differences found 125 # 1: differences found 126 # >1: error 127 if [ -e $schedulefile2old ] 128 then 129 if diff $schedulefile2 $schedulefile2old >/dev/null 130 then 131 printprocesslog "INFO Schedule did not change." 132 continue 133 else 134 update="(upd)" 135 fi 136 else 137 update="(new)" 138 fi 83 139 84 140 # output list of sources … … 109 165 echo -e "\nNone of the sources was found in the Swift schedule." >> $schedulefile3 110 166 else 111 echo "night of "$date": " && cat $schedulefile3 | grep -v Searched | sort167 echo "night of "$date": "$update && cat $schedulefile3 | grep -v Searched | sort 112 168 fi 113 169
Note:
See TracChangeset
for help on using the changeset viewer.