source: trunk/DataCheck/Monitoring/CheckSwiftSchedule.sh@ 18702

Last change on this file since 18702 was 18692, checked in by Daniela Dorner, 8 years ago
changed from https to http as certificate caused problems after upgrade of system
  • Property svn:executable set to *
File size: 3.9 KB
Line 
1#!/bin/bash
2
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6
7# list of sources
8sources=( "Mrk 421" "Mkn 421" "Mkn421" \
9 "1959" "V404" \
10 "1H 0323+342" "RXJ0324.6+3410" "RGBJ0324+3410" "SWIFTJ0325.3-5916"
11 "Crab" "CRAB" \
12 "Mrk 501" "Mkn 501" \
13 "1ES 2344+514" "1ES2344+514" )
14
15# target ids:
16# http://www.swift.ac.uk/swift_live/index.php
17
18# 0323: 90415, 36533, 34137, 35372, 35630
19# http://www.swift.ac.uk/swift_live/doSimpleSearch.php?catname=swiftmastr&searchpos=1H+0323%2B342&searchrad=12&searchepoch=2000&getWhat=1&sortBy=_r&dandr=on&coordType=0&retEpoch=2000&retType=0&retWhere=1
20
21# Mrk421: 30352, 35014, 215769, 31202, 80050, 31540, 91137, 34228, tbc
22# http://www.swift.ac.uk/swift_live/doSimpleSearch.php?catname=swiftmastr&searchpos=Mrk+421&searchrad=12&searchepoch=2000&getWhat=1&sortBy=_r&dandr=on&coordType=0&retEpoch=2000&retType=0&retWhere=2
23
24# get dates
25if [ "$certaindate" != "" ]
26then
27 getdates $certaindate
28else
29 if [ "$1" = "" ]
30 then
31 # get next 3 night
32 getdates +3
33 else
34 getdates $1
35 fi
36fi
37
38
39
40for date in ${dates[@]}
41do
42 printprocesslog "INFO getting Swift schedule for the night of "$date
43 #echo "INFO getting Swift schedule for the night of "$date
44 # paths and files needed to store schedule
45 date2=`echo $date | sed -e 's/\//-/g'`
46 schedulepath=/home/factwww/scheduling/$date
47 if [ ! -d $schedulepath ]
48 then
49 printprocesslog "WARNING "$schedulingpath" does not exist."
50 echo "WARNING "$schedulingpath" does not exist."
51 continue
52 fi
53 schedulefile=$schedulepath/swift.schedule
54 schedulefile2=$schedulepath/swift.schedule.formated
55 schedulefile3=$schedulepath/swift.schedule.txt
56
57 # overwrite already existing file
58 echo "" > $schedulefile
59 # Get Swift Data
60 # for the date of sunset
61 printprocesslog "INFO Checking "$date2
62 lynx -width 200 -nolist -dump http://www.swift.psu.edu/operations/obsSchedule.php?d=$date2 | grep $date2 >> $schedulefile
63 # for the date of sunrise
64 nextday=`date +%Y-%m-%d --date=$date2"+24hour"`
65 printprocesslog "INFO Checking "$nextday
66 lynx -width 200 -nolist -dump http://www.swift.psu.edu/operations/obsSchedule.php?d=$nextday | grep $nextday >> $schedulefile
67
68 # check if schedule is empty
69 checkcontent=`cat $schedulefile`
70 if [ "$checkcontent" = "" ]
71 then
72 printprocesslog "INFO No Schedule found for the night of "$date
73 continue
74 fi
75
76 # grep only the columns which are needed
77 cat $schedulefile | sed -r -e 's/[0-9]{5}\ \ \ [0-9]{1,3}\ \ \ //' | grep -o -E '^\ \ \ \ 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
78
79 # output list of sources
80 echo -n "Searched the schedule for the following source names: " >$schedulefile3
81 for (( i=0; i<${#sources[@]}; i++ ))
82 do
83 echo -n ${sources[$i]} >>$schedulefile3
84 i2=`echo " $i + 1" | bc -l`
85 if [ $i2 -lt ${#sources[@]} ]
86 then
87 echo -n ", " >>$schedulefile3
88 else
89 echo "" >>$schedulefile3
90 fi
91 done
92
93 printprocesslog "INFO searching the Swift schedule for the following sources: "${sources[@]}
94 # search for source names in schedule file
95 for (( i=0; i<${#sources[@]}; i++ ))
96 do
97 grep "${sources[$i]}" $schedulefile2 >>$schedulefile3
98 done
99
100 # check if a source was found
101 numfound=`cat $schedulefile3 | wc -l`
102 if [ $numfound -eq 1 ]
103 then
104 echo -e "\nNone of the sources was found in the Swift schedule." >> $schedulefile3
105 fi
106
107 # output link to full schedule
108 echo -e "\nThe full schedule can be found <a href='../scheduling/"$date"/"`basename $schedulefile2`"'>here</a>\n" >>$schedulefile3
109
110 printprocesslog "INFO schedule output stored to "$schedulefile3
111done
112
113finish
Note: See TracBrowser for help on using the repository browser.