Changeset 983


Ignore:
Timestamp:
02/14/14 18:52:08 (10 years ago)
Author:
sdipsl
Message:

bypass firewalling difficulties. use mailing system to send AMQP message
see #176

Location:
trunk/libIGCM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh

    r980 r983  
    790790            (( i=i+3 )) 
    791791          done 
    792  
    793792        else 
    794793          if [ X${FileName0} != XNONE ] ; then 
  • trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh

    r941 r983  
    142142 
    143143#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 
     147function 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-#================================================================== 
    144194#D-function IGCM_debug_SendAMQP 
    145195#D- * Purpose: Send body; encoded body and config.card to rabbitMQ 
     
    167217    (( decal = decal + 1 )) 
    168218  done 
    169   # Log to stack file 
     219  # Log to stack file using human readable format 
    170220  echo sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b "${Body}"      >> ${StackFileLocation}/${StackFileName} 
    171221 
    172   # Log separately AMQP send message command 
     222  # Log separately encoded AMQP message command for reuse in a mock up 
    173223  echo sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody} >> /tmp/send.AMQP.${jobid}.history.txt 
    174224 
    175225  # 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 
    177234  status=$? 
    178235  if [ ${status} -gt 0 ] ; then 
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys.ksh

    r926 r983  
    2626# set BigBrother false by default 
    2727BigBrother=false 
     28 
     29#==================================================== 
     30# set BigBrother channel (AMQP or MAIL) 
     31# only MAIL working at present due to firewall constraint 
     32BigBrotherChannel=MAIL 
    2833 
    2934# variable that must have lower case value. 
Note: See TracChangeset for help on using the changeset viewer.