ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/proj/workflow/scripts/show_jsoc_proc_status.csh
Revision: 1.4
Committed: Wed Jun 20 18:00:16 2012 UTC (11 years, 3 months ago) by arta
Content type: application/x-csh
Branch: MAIN
CVS Tags: Ver_6-4, Ver_8-0, Ver_7-1, Ver_7-0
Changes since 1.3: +1 -1 lines
Log Message:
Move fetch_log to /home/jsoc/exports/logs so that apache can create an empty log when needed.

File Contents

# Content
1 #! /bin/csh -f
2
3 # set echo
4
5 set TARG = /web/jsoc/htdocs/data
6 set TMP = $TARG/.jsoc_proc_status.tmp
7
8 set noglob
9 unsetenv QUERY_STRING
10
11 set SHOW_INFO = /home/jsoc/cvs/Development/JSOC/bin/linux_x86_64/show_info
12 #set SHOW_INFO = /home/jsoc/cvs/Development/JSOC/bin/linux_x86_64/show_info
13 #set SHOW_SERIES = /home/jsoc/cvs/Development/JSOC/bin/linux_x86_64/show_series
14 set SHOW_SERIES = /home/jsoc/cvs/Development/JSOC/bin/linux_x86_64/show_series
15 set TIME_CONVERT = /home/jsoc/cvs/Development/JSOC/bin/linux_x86_64/time_convert
16 set ARITH = /home/phil/bin/_linux4/arith
17 set USERDB=hmidb
18 set USERDB2=hmidb2
19
20 @ fourdays = 4 * 1440
21 @ fivedays = 5 * 1440
22 @ sixdays = 6 * 1440
23 @ oneweek = 7 * 1440
24
25 # HMI products
26 set hproduct = ( hmi.lev0a hmi.lev1_nrt hmi.V_45s_nrt hmi.V_720s_nrt hmi_images hmi.lev1 hmi.cosmic_rays hmi.V_45s hmi.V_720s)
27 set hgreen = ( 2 5 30 60 43 $fivedays $fivedays $sixdays $sixdays)
28 set hyellow = ( 4 10 60 80 60 $fivedays $fivedays $sixdays $sixdays)
29 set hred = ( 8 20 120 150 150 $sixdays $sixdays $oneweek $oneweek)
30
31 # AIA products
32 set aproduct = ( aia.lev0 aia.lev1_nrt2 aia_test.lev1p5 aia.lev1 )
33 set agreen = ( 3 5 15 $fivedays )
34 set ayellow = ( 4 10 20 $fivedays )
35 set ared = (8 20 40 $sixdays )
36
37 set product = ( $hproduct $aproduct )
38 set green = ($hgreen $agreen)
39 set yellow = ($hyellow $ayellow)
40 set red = ($hred $ared)
41
42 @ r = 0
43 @ y = 0
44 @ g = 0
45
46 set now = `date -u +%Y.%m.%d_%H:%M:%S`
47 set now_t = `$TIME_CONVERT time=$now`
48
49 #echo "Content-type: text/html" >$TMP
50 #echo "" >>$TMP
51 #echo '<HTML><HEAD><TITLE>JSOC Processing Status</TITLE><META HTTP-EQUIV="Refresh" CONTENT="60"></HEAD><BODY>' >>$TMP
52 echo '<HTML><HEAD><TITLE>JSOC Processing Status</TITLE><META HTTP-EQUIV="Refresh" CONTENT="60"></HEAD><BODY>' >$TMP
53 echo -n "Last Update "$now"_UTC -- " >>$TMP
54 date >>$TMP
55
56 echo '<P><TABLE>' >>$TMP
57 echo '<TR><TD>Product</TD><TD>Lag</TD><TD>Note</TD></TR>' >>$TMP
58
59 set nprod = $#product
60 set iprod = 1
61 set project = hmi
62 while ($iprod <= $nprod)
63 set prod = $product[$iprod]
64 if ($prod == hmi.lev0a) then
65 set times = `$SHOW_INFO key=T_OBS -q hmi.lev0a'[? FSN < 200000000 ?]' n=-1`
66 else if ($prod == aia.lev0) then
67 set times = `$SHOW_INFO key=T_OBS -q aia.lev0'[? FSN < 200000000 ?]' n=-1`
68 else if ($prod == hmi_images) then
69 set times = ` head -1 /web/jsoc/htdocs/data/hmi/images/image_times`
70 set times = `echo $times[2] | awk -- 'BEGIN {FIELDWIDTHS = "4 2 2 1 2 2 2"} {printf("%s.%s.%s_%s:%s:%s_TAI",$1,$2,$3,$5,$6,$7)}'`
71 else
72 set times = `$SHOW_INFO -q key=T_OBS $prod'[$]'`
73 if ( $times[1] == '-4712.01.01_11:59:28_TAI' ) then # added by Jeneen 3/23/11
74 set times = `$SHOW_INFO -q key=T_REC $prod'[$]'`
75 endif
76 if ($prod == hmi.V_45s) then
77 echo $times[1] > $TARG/hmi_45s_latest.txt
78 else if ($prod == hmi.V_720s) then
79 echo $times[1] > $TARG/hmi_720s_latest.txt
80 endif
81 endif
82 set times_t = `$TIME_CONVERT time=$times[1]`
83 @ lags = ( $now_t - $times_t ) / 60
84 if ($lags <= $green[$iprod]) then
85 set stat = GREEN
86 @ g = 1
87 else if ($lags <= $yellow[$iprod]) then
88 set stat = YELLOW
89 @ y = 1
90 else
91 set stat = RED
92 @ r = 1
93 endif
94 if ($lags < 60) then
95 set lag = "$lags minutes"
96 else if ($lags < 1440) then
97 set hours = `$ARITH $lags / 60`
98 set lag = "$hours hours"
99 else
100 set days = `$ARITH $lags / 1440`
101 set lag = "$days days"
102 endif
103 if ($prod == hmi_images) then
104 set note = "HMI nrt web images"
105 else
106 set note = `$SHOW_SERIES -p '^'$prod'$' | grep "Note:" | sed -e 's/"/'"'/"`
107 shift note
108 endif
109 if (!($prod =~ "$project"*)) then
110 echo '<TR><TD>&nbsp;<TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>' >>$TMP
111 set project = $prod:r
112 endif
113 echo -n '<TR><TD>'$prod'</TD><TD' >>$TMP
114 if ($stat == GREEN) then
115 echo -n ' BGCOLOR="#66FF66">' >>$TMP
116 else if ($stat == YELLOW) then
117 echo -n ' BGCOLOR="yellow">' >>$TMP
118 else
119 echo -n ' BGCOLOR="#FF6666">' >>$TMP
120 endif
121 echo "$lag"'</TD><TD>'"$note"'</TD></TR>' >>$TMP
122 @ iprod = $iprod + 1
123 end
124
125 # get lookdata and exportdata responsiveness
126 set webinfo = `tail -30 /home/jsoc/exports/logs/fetch_log | awk 'BEGIN { min=100000; max=0} {for (i=1; i<NF; i++) if ($i ~ /lag=.*/) {sub(/lag=/,"",$i); lag=$i}} {sum += lag; n++; } lag<min{min=lag} lag>max{max=lag} END { avg = sum/n; print sprintf("%0.3f",avg) " min=" min " max=" max }'`
127 echo '<TR><TD>&nbsp;<TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>' >>$TMP
128 echo -n '<TR><TD>web response</TD><TD' >>$TMP
129 set lag=$webinfo[1]
130
131 set mslag = `echo $lag | sed -e "s/\.//" -e "s/^0*//"`
132 if ($mslag < 5000) then
133 echo -n ' BGCOLOR="#66FF66">' >>$TMP
134 else if ($mslag < 20000) then
135 echo -n ' BGCOLOR="yellow">' >>$TMP
136 else
137 echo -n ' BGCOLOR="#FF6666">' >>$TMP
138 endif
139 echo "$lag"'s</TD><TD>'$webinfo[2]'s, '$webinfo[3]'s, lookdata, exportdata response</TD></TR>' >>$TMP
140
141 ### Added 12/5/11 for monitoring exports ###
142
143 set count1 = `wget -O - -q 'http://jsoc2.stanford.edu/cgi-bin/ajax/show_info?c=1&q=1&ds=jsoc.export_new[?status=2?]'`
144 #echo -n $count1
145 set count2 = `wget -O - -q 'http://jsoc.stanford.edu/cgi-bin/ajax/show_info?c=1&q=1&ds=jsoc.export_new[?status=2?]'`
146
147 echo '<TR><TD>Export Processing </TD><TD' >> $TMP
148
149 if ($count1 < 2) then
150 echo -n ' BGCOLOR="#66FF66">' >>$TMP
151 else if ( ($count1 >= 2) && ($count1 < 6) ) then
152 echo -n ' BGCOLOR="yellow">' >>$TMP
153 else
154 echo -n ' BGCOLOR="#FF6666">' >>$TMP
155 endif
156 echo "$count1"' </TD><TD> Number of exports pending on ' $USERDB'</TD></TR>' >>$TMP
157
158
159 echo '<TR><TD>Export Processing </TD><TD' >> $TMP
160
161 if ($count2 < 2) then
162 echo -n ' BGCOLOR="#66FF66">' >>$TMP
163 else if ( ($count2 >= 2) && ($count2 < 6) ) then
164 echo -n ' BGCOLOR="yellow">' >>$TMP
165 else
166 echo -n ' BGCOLOR="#FF6666">' >>$TMP
167 endif
168 echo "$count2"' </TD><TD> Number of exports pending on ' $USERDB2'</TD></TR>' >>$TMP
169
170 ### End of export monitoring ###
171
172 echo '</TABLE>' >>$TMP
173 echo '<P>' >>$TMP
174 echo 'Data times given are lag between observation time and the current time.' >>$TMP
175 echo '<BR>' >>$TMP
176 echo 'Web times given are sample of most recent 30 requests, avg, min, max.' >>$TMP
177 echo '<BR>' >>$TMP
178 echo 'Colors indicate: green -> as expected; yellow -> late; red -> very late' >>$TMP
179 echo '<P>' >>$TMP
180
181 if ($r == 1) then
182 set favicon = red_sq.gif
183 /home/jeneen/campaigns/scripts/hmi/update_proc_status.csh red
184 else if ($y == 1) then
185 set favicon = yellow_sq.gif
186 /home/jeneen/campaigns/scripts/hmi/update_proc_status.csh yellow
187 else
188 set favicon = green_sq.gif
189 /home/jeneen/campaigns/scripts/hmi/update_proc_status.csh green
190 endif
191 echo '</BODY>' >>$TMP
192 #echo '<HEAD><link rel="stat icon" href="http://jsoc.stanford.edu/data/tmp/favicon.ico"></HEAD>' >>$TMP
193 echo '<HEAD><link rel="stat icon" href="http://jsoc.stanford.edu/data/tmp/'$favicon'"></HEAD>' >>$TMP
194 echo '</HTML>' >>$TMP
195
196 mv $TMP $TARG/jsoc_proc_status.html