Changeset 983 for trunk/libIGCM/libIGCM_debug
- Timestamp:
- 02/14/14 18:52:08 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh
r941 r983 142 142 143 143 #D-#================================================================== 144 #D-function IGCM_debug_send_AMQP_msg__MAILTUNNEL 145 #D- * Purpose: Take over AMQP C client using mail as a message recipient 146 #D- * One argument : base64 encoded message 147 function IGCM_debug_send_AMQP_msg__MAILTUNNEL { 148 149 typeset b64_encoded_msg buffer mail_recipient send_messages mail_frequency last_mail_date__file 150 b64_encoded_msg=$1 151 152 buffer=/tmp/buffer.$$ 153 mail_recipient="jerome.raciazek@ipsl.jussieu.fr" 154 send_messages=0 155 mail_frequency=3600 # in seconds 156 # use to keep track when was last mail sent (maybe to be replaced with global variable) 157 last_mail_date__file=/tmp/stamp.$$ 158 159 # init 160 if [ ! -f "${buffer}" ]; then 161 touch "${buffer}" 162 fi 163 164 messages_count=$( wc -l ${buffer} ) # retrieve how many pending messages 165 166 if [ ! -f "${last_mail_date__file}" ]; then 167 # if we are here, it means no mail sent yet 168 if [ ${messages_count} -gt 0 ]; then 169 # send the first mail 170 send_messages=1 171 fi 172 else 173 # compute last time the file was changed (in seconds) 174 seconds_since_last_mail=$(( $(date +%s) - $(stat -c %Y ${last_mail_date__file}) )) 175 176 if [ ${seconds_since_last_mail} -gt ${mail_frequency} ]; then 177 send_messages=1 178 fi 179 fi 180 181 # send mail / add message in buffer 182 if [ ${send_messages} -eq 1 ]; then 183 cat ${buffer} | mail -s mail_recipient # send buffer 184 > $buffer # clear buffer 185 touch ${last_mail_date__file} # memorize last mail date 186 else 187 echo ${b64_encoded_msg} >> ${buffer} 188 fi 189 # Allways all good for now. 190 return 0 191 } 192 193 #D-#================================================================== 144 194 #D-function IGCM_debug_SendAMQP 145 195 #D- * Purpose: Send body; encoded body and config.card to rabbitMQ … … 167 217 (( decal = decal + 1 )) 168 218 done 169 # Log to stack file 219 # Log to stack file using human readable format 170 220 echo sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b "${Body}" >> ${StackFileLocation}/${StackFileName} 171 221 172 # Log separately AMQP send message command222 # Log separately encoded AMQP message command for reuse in a mock up 173 223 echo sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody} >> /tmp/send.AMQP.${jobid}.history.txt 174 224 175 225 # Send the message 176 sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody} 226 if [ X${BigBrotherChannel} = XMAIL ] ; then 227 IGCM_debug_send_AMQP_msg__MAILTUNNEL "${encodedBody}" 228 status=$? 229 else 230 sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody} 231 status=$? 232 fi 233 177 234 status=$? 178 235 if [ ${status} -gt 0 ] ; then
Note: See TracChangeset
for help on using the changeset viewer.