Changeset 913


Ignore:
Timestamp:
08/12/13 15:06:43 (11 years ago)
Author:
sdipsl
Message:

refactoring (supervisor related blocks)
introducing revisited instrumentation from CEA audit see #140
IGCM_sys_Get* IGCM_sys_rebuild* have instrumentation
IGCM_sys_Put* IGCM_sys_nc* IGCM_sys_cdo IGCM_sys_tar not yet instrumented
Not fully tested yet. Use at your own risks

File:
1 edited

Legend:

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

    r894 r913  
    1 #!/bin/ksh  
     1#!/bin/ksh 
    22 
    33#************************************************************** 
     
    1414#================================================== 
    1515# The documentation of this file can be automatically generated 
    16 # if you use the prefix #D- for comments to be extracted.  
     16# if you use the prefix #D- for comments to be extracted. 
    1717# Extract with command: cat lib* | grep "^#D-" | cut -c "4-" 
    1818#================================================== 
     
    4646# NULL_STR 
    4747# Default null string 
    48 typeset -r NULL_STR="_0_"  
     48typeset -r NULL_STR="_0_" 
    4949 
    5050#================================================== 
    5151# libIGCM_CurrentTag 
    5252# Current libIGCM tag, check compatibilty with *.card 
    53 typeset -r libIGCM_CurrentTag="1.0"  
     53typeset -r libIGCM_CurrentTag="2.0" 
    5454 
    5555#================================================== 
     
    6060#================================================== 
    6161# Declare a stack of functions calls 
    62  
    63 # insert last argument of the Stack 
    64 #set -A IGCM_debug_Stack ${NULL_STR} 
    65 #set -A IGCM_debug_StackArgs ${NULL_STR} 
    6662unset IGCM_debug_Stack 
    6763unset IGCM_debug_StackArgs 
     64unset IGCM_debug_StackTiming 
    6865IGCM_debug_Stack[0]=${NULL_STR} 
    6966IGCM_debug_StackArgs[0]=${NULL_STR} 
     67IGCM_debug_StackTiming[0]=${NULL_STR} 
    7068IGCM_debug_LenStack=0 
    7169 
    7270#D-#================================================================== 
     71#D-function IGCM_debug_getDate_ms 
     72#D- * Purpose: Give number of milliseconds since 01-jan-1970 
     73function IGCM_debug_getDate_ms 
     74{ 
     75  typeset nanosecs testnum 
     76  # nano secondes since 01-jan-1970 
     77  nanosecs=$( date +%s%N ) 
     78 
     79  # truncate the last 6 digits to get milliseconds since 01-jan-1970 
     80  ms=${nanosecs:0:${#nanosecs}-6} 
     81 
     82  echo "$ms" 
     83} 
     84 
     85#D-#================================================================== 
     86#D-function IGCM_debug_sizeOfTabContent 
     87#D- * Purpose: Give sumed size of a list of files 
     88function IGCM_debug_sizeOfTabContent 
     89{ 
     90  typeset dm_liste sizeFile sizeKo sizeMo 
     91  eval set +A dm_liste \${${1}} 
     92  sizeKo=0 
     93  for ((i = 0; i < ${#dm_liste[*]}; i += 1)) ; do 
     94    # echo "dm_liste[$i]=${dm_liste[$i]}" 
     95    # remove path /home/login/../ from dm_liste elements 
     96    sizeFile=$( du --apparent-size -k ${dm_liste[$i]##/*/} ) 
     97    sizeKo=$(( $sizeKo + $sizeFile )) 
     98  done 
     99  sizeMo=$( echo "scale=6;${sizeKo}/1024" | bc ) 
     100  echo "${sizeKo}|${sizeMo}" 
     101} 
     102 
     103#D-#================================================================== 
     104#D-function IGCM_debug_SendAMQP 
     105#D- * Purpose: Send body; encoded body and config.card to rabbitMQ 
     106function IGCM_debug_sendAMQP 
     107{ 
     108  typeset decal first additionnalOption encodedBody 
     109 
     110  # Encode message Body 
     111  encodedBody=$( echo "${Body}" | base64 -w 0 ) 
     112 
     113  # Send config.card ? 
     114  if [ X${1} = Xactivate ] ; then 
     115    # Encode config.card 
     116    cat ${SUBMIT_DIR}/config.card | base64 -w 0 > ${SUBMIT_DIR}/config.card.base64 
     117    # Prepare additionnal option 
     118    additionnalOption="-f ${SUBMIT_DIR}/config.card.base64" 
     119  else 
     120    additionnalOption= 
     121  fi 
     122 
     123  # Only cosmetics : stack file 
     124  decal=0 
     125  while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do 
     126    printf ' ' >> ${StackFileLocation}/stack 
     127    (( decal = decal + 1 )) 
     128  done 
     129  # Log to stack file 
     130  echo sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b "${Body}"      >> ${StackFileLocation}/stack 
     131 
     132  # Log separately AMQP send message command 
     133  echo sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody} >> /tmp/send.AMQP.${jobid}.history.txt 
     134 
     135  # Send the message 
     136  sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody} 
     137  status=$? 
     138  if [ ${status} -gt 0 ] ; then 
     139    IGCM_debug_Print 2 "IGCM_debug_Push/PopStack/ActivateBigBro : command sendAMQPMsg failed error code ${status}" 
     140    echo  sendAMQPMsg -h localhost -p 5672 -b "${Body}" 
     141    exit 
     142  fi 
     143} 
     144 
     145#D-#================================================================== 
    73146#D-function IGCM_debug_CallStack 
    74 #D-* Purpose: Echo the Stack 
     147#D-* Purpose: Print the call stack tree from the oldest to the youngest (opposite of the display standard) 
    75148#D- 
    76149function IGCM_debug_CallStack { 
    77150  if ( $DEBUG_debug ) ; then 
    78     # La pile d'appels est affichée de la plus vieille à la plus récente  
    79     # (c'est donc l'inverse de la norme d'affichage). 
     151    # Cosmetics 
    80152    typeset i decal 
    81153    i=0 
     
    89161      ((i = i + 1)) 
    90162    done 
    91     #echo "!------------------------!" 
    92163  fi 
    93164} 
     
    98169#D- 
    99170function IGCM_debug_PushStack { 
    100  
    101171  if ( $DEBUG_debug ) ; then 
    102     typeset decal inputs 
     172    typeset decal inputs startTime_ms 
    103173    echo >> ${StackFileLocation}/stack 
     174 
     175    # Only cosmetics : stack file 
    104176    decal=0 
    105177    while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do 
     
    108180    done 
    109181 
    110     # STORE input list in an indexed array 
     182    # Save input list in an indexed array 
    111183    INPUTS=( $@ ) 
     184 
     185    # Get timing information 
     186    startTime_ms=$( IGCM_debug_getDate_ms ) 
     187 
    112188    # We add function call name on beginning of the stack 
    113189    set +A IGCM_debug_Stack -- ${1} ${IGCM_debug_Stack[*]} 
    114190 
     191    # Save timing in milliseconds in an indexed array 
     192    set +A IGCM_debug_StackTiming -- ${startTime_ms} ${IGCM_debug_StackTiming[*]} 
     193 
    115194    # We include the "null" Args in the beginning of the StackArgs 
    116     set +A IGCM_debug_StackArgs ${NULL_STR} ${IGCM_debug_StackArgs[*]}  
     195    set +A IGCM_debug_StackArgs ${NULL_STR} ${IGCM_debug_StackArgs[*]} 
     196 
    117197    # Then, we shift StackArgs tabular 
    118     if [ $# -gt 1 ]; then  
    119       IGCM_debug_StackArgs[0]=$(echo ${INPUTS[*]:1} | sed -e "s/\ /,/g") 
     198    if [ $# -gt 1 ]; then 
     199      IGCM_debug_StackArgs[0]=$(echo ${INPUTS[*]:1} | sed -e "s/\ /,/g" ) 
    120200    fi 
    121201 
     
    123203    echo "> ${IGCM_debug_LenStack} : ${@}" >> ${StackFileLocation}/stack 
    124204 
    125     # Fill the rabbitMQ queue 
    126  
    127     # TO BE A FUNCTION BEGIN # 
    128  
    129205    if [ X${ActivateBigBro} = Xtrue ] ; then 
    130       # Only cosmetics 
    131       decal=0 
    132       while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do 
    133         printf ' ' >> ${StackFileLocation}/stack 
    134         (( decal = decal + 1 )) 
    135       done 
    136       # RabbitMQ message 
     206      # RabbitMQ message code 
    137207      code=2000 
    138       # 
     208      # RabbitMQ message body 
    139209      Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" ) 
    140       encodedBody=$( echo "${Body}" | base64 -w 0 ) 
    141       # 
    142       #sendAMQPMsg -h localhost -p 5672 -f ${SUBMIT_DIR}/config.card.base64 -b ${encodedBody} 
    143       echo sendAMQPMsg -h localhost -p 5672 -b "${Body}"      >> ${StackFileLocation}/stack 
    144       echo sendAMQPMsg -h localhost -p 5672 -b ${encodedBody} >> /tmp/send.AMQP.${jobid}.history.txt 
    145       sendAMQPMsg -h localhost -p 5672 -b ${encodedBody} 
    146       status=$? 
    147       if [ ${status} -gt 0 ] ; then 
    148         IGCM_debug_Print 2 "IGCM_debug_PushStack : command sendAMQPMsg failed error code ${status}" 
    149         echo  sendAMQPMsg -h localhost -p 5672 -b "${Body}" 
    150         exit 
    151       fi 
    152     fi 
    153  
    154     # TO BE A FUNCTION END # 
     210      # Fill the rabbitMQ queue 
     211      IGCM_debug_sendAMQP 
     212    fi 
    155213 
    156214    # Increment LenStack 
    157215    (( IGCM_debug_LenStack = IGCM_debug_LenStack + 1 )) 
    158216 
    159     # If you want to print CallStack each time : 
    160217    #IGCM_debug_CallStack 
    161218  fi 
     
    168225function IGCM_debug_PopStack { 
    169226  if ( $DEBUG_debug ) ; then 
    170     typeset decal 
     227    typeset decal command arguments startTime_ms endTime_ms 
     228    typeset fileList source dest 
     229 
     230    # INTRODUCE SIMPLE ERROR GENERATOR TO TEST SUPERVISOR 
     231    # PROBABILITY ERROR IS 0.0001 PER COMMAND OR FUNCTION CALL 
     232    # THERE ARE ~500 COMMAND OR FUNCTION CALL PER PERIOD 
     233    if ( ${RandomError} ) ; then 
     234      if [ $((RANDOM%10000)) -le 10 ] ; then 
     235        IGCM_debug_Print 1 "Random error has been triggered" 
     236        echo "RANDOM ERROR" >> ${StackFileLocation}/stack 
     237        ExitFlag=true 
     238      fi 
     239    fi 
     240 
    171241    if [ "${IGCM_debug_Stack[0]}" = "${1}" ]; then 
     242      # Everything is cool 
     243 
     244      # Get timing information 
     245      endTime_ms=$( IGCM_debug_getDate_ms ) 
     246 
     247      # Save Stack information before poping the stack 
     248      command=${IGCM_debug_Stack[0]} 
     249 
     250      # Go from comma separated (list) to space separated in an array 
     251      set -A arguments $( echo ${IGCM_debug_StackArgs[0]} | sed -e "s/,/\ /g" ) 
     252 
     253      # Save Stack information before poping the stack 
     254      startTime_ms=${IGCM_debug_StackTiming[0]} 
     255 
     256      # Pop the stack 
    172257      (( IGCM_debug_LenStack = IGCM_debug_LenStack - 1 )) 
    173258      set -A IGCM_debug_Stack -- ${IGCM_debug_Stack[*]:1} 
    174259      set -A IGCM_debug_StackArgs -- ${IGCM_debug_StackArgs[*]:1} 
     260      set -A IGCM_debug_StackTiming -- ${IGCM_debug_StackTiming[*]:1} 
    175261    else 
    176262      echo 'IGCM_debug_Exit : stack is corrupted ! LenStack =' ${IGCM_debug_LenStack} 
    177263      IGCM_debug_Exit $@ 
    178264    fi 
     265 
     266    # Special actions depending on command to prepare IGCM_debug_PrintInfosAction call 
     267    # We are interested in: 
     268    #  0. Which command performs the work 
     269    #  1. Size of entity we are working with 
     270    #  2. Where are we reading 
     271    #  3. Where are we writing 
     272    #  4. How long it took 
     273 
     274    case ${command} in 
     275    # Copy from archive machine or from buffer 
     276    IGCM_sys_Get|IGCM_sys_GetBuffer) 
     277      if [ ${#arguments[*]} -eq 2 ] ; then 
     278        source=${arguments[0]} 
     279        dest=${arguments[1]} 
     280        # Size of file whose name are stored in a variable 
     281        entitySize=$( IGCM_debug_sizeOfTabContent source ) 
     282      elif ( [ ${#arguments[*]} -eq 3 ] && [ ${arguments[0]} = '/l' ] ) ; then 
     283        # Keep the array name hosting the all list 
     284        fileList=${arguments[0]} 
     285        # just need the first file to get the directory 
     286        eval source=\${${arguments[0]}[0]} 
     287        dest=${arguments[1]} 
     288        # Size of file whose name are stored in an array 
     289        entitySize=$( IGCM_debug_sizeOfTabContent fileList[*] ) 
     290      elif [ [ ${#arguments[*]} -ge 3 ] ; then 
     291       # All but the latest 
     292        fileList=${arguments[*]:0:${#arguments[*]}-2} 
     293        # just need the first file to get the directory 
     294        source=${arguments[0]} 
     295        # Nothing but the latest 
     296        dest=${arguments[${#arguments[*]}-1]} 
     297        # Size of file whose name are stored in a list 
     298        entitySize=$( IGCM_debug_sizeOfTabContent fileList ) 
     299      fi 
     300      ;; 
     301 
     302    # Copy from compute node 
     303    IGCM_sys_Get_Master|IGCM_sys_Get_Dir) 
     304      if [ ${#arguments[*]} -eq 2 ] ; then 
     305        source=${arguments[0]} 
     306        dest=${arguments[1]} 
     307        # Size of file whose name are stored in a variable 
     308        entitySize=$( IGCM_debug_sizeOfTabContent source ) 
     309      fi 
     310      ;; 
     311 
     312    # Rebuild command 
     313    IGCM_sys_rebuild|IGCM_sys_rebuild_station) 
     314      # All but the first 
     315      fileList=${arguments[*]:1:${#arguments[*]}-1} 
     316      # just need a file to get the directory 
     317      source=${arguments[1]} 
     318      # Nothing but the first 
     319      dest=${arguments[0]} 
     320      # Size of file whose name are stored in a list 
     321      entitySize=$( IGCM_debug_sizeOfTabContent fileList ) 
     322      ;; 
     323    esac 
     324 
     325    # Print information related to instrumentation 
     326    IGCM_debug_PrintInfosAction ${command} ${entitySize} ${startTime_ms} ${endTime_ms} ${dest} ${source} 
     327 
     328    # Only cosmetics : stack file 
    179329    decal=0 
    180330    while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do 
     
    183333    done 
    184334 
    185     # INTRODUCE SIMPLE ERROR GENERATOR TO TEST SUPERVISOR 
    186     # PROBABILITY ERROR IS 0.0001 PER COMMAND OR FUNCTION CALL 
    187     # THERE ARE ~500 COMMAND OR FUNCTION CALL PER PERIOD 
    188     #  
    189     if ( ${RandomError} ) ; then 
    190       if [ $((RANDOM%10000)) -le 10 ] ; then 
    191         IGCM_debug_Print 1 "A random error has been triggered" 
    192         echo "RANDOM ERROR" >> ${StackFileLocation}/stack 
    193         ExitFlag=true 
    194       fi 
    195     fi 
    196  
    197335    if ( ${ExitFlag} ) ; then 
    198336      # Inform the stack file 
    199337      echo '!!! ExitFlag has been activated !!!' >> ${StackFileLocation}/stack 
    200       # Inform the rabbitMQ queue 
    201  
    202       # TO BE A FUNCTION BEGIN # 
    203338 
    204339      if [ X${ActivateBigBro} = Xtrue ] ; then 
    205         # Only cosmetics 
    206         decal=0 
    207         while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do 
    208           printf ' ' >> ${StackFileLocation}/stack 
    209           (( decal = decal + 1 )) 
    210         done 
    211         # RabbitMQ message 
     340        # RabbitMQ message code 
    212341        code=9000 
    213         # 
     342        # RabbitMQ message body 
    214343        Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"NOK\",\"out\":\"true\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" ) 
    215         encodedBody=$( echo "${Body}" | base64 -w 0 ) 
    216         # 
    217         #sendAMQPMsg -h localhost -p 5672 -f ${SUBMIT_DIR}/config.card -b ${encodedBody} 
    218         echo sendAMQPMsg -h localhost -p 5672 -b "${Body}"      >> ${StackFileLocation}/stack 
    219         echo sendAMQPMsg -h localhost -p 5672 -b ${encodedBody} >> /tmp/send.AMQP.${jobid}.history.txt 
    220         sendAMQPMsg -h localhost -p 5672 -b ${encodedBody} 
    221         status=$? 
    222         if [ ${status} -gt 0 ] ; then 
    223           IGCM_debug_Print 2 "IGCM_debug_PopStack : command sendAMQPMsg failed error code ${status}" 
    224           echo  sendAMQPMsg -h localhost -p 5672 -b "${Body}" 
    225           exit 
    226         fi 
     344        # Fill the rabbitMQ queue 
     345        IGCM_debug_sendAMQP 
    227346      fi 
    228  
    229       # TO BE A FUNCTION END # 
    230  
    231347    else 
    232348      # Inform the stack file 
    233349      echo "< ${IGCM_debug_LenStack} : ${@}" >> ${StackFileLocation}/stack 
    234  
    235       # Inform the rabbitMQ queue 
    236  
    237       # TO BE A FUNCTION BEGIN # 
    238  
    239350      if [ X${ActivateBigBro} = Xtrue ] ; then 
    240         # Only cosmetics 
    241         decal=0 
    242         while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do 
    243           printf ' ' >> ${StackFileLocation}/stack 
    244           (( decal = decal + 1 )) 
    245         done 
    246         # RabbitMQ message 
     351        # RabbitMQ message code 
    247352        code=3000 
    248         # 
     353        # RabbitMQ message body 
    249354        Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"OK\",\"out\":\"true\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" ) 
    250         encodedBody=$( echo "${Body}" | base64 -w 0 ) 
    251         # 
    252         echo sendAMQPMsg -h localhost -p 5672 -b "${Body}"      >> ${StackFileLocation}/stack 
    253         echo sendAMQPMsg -h localhost -p 5672 -b ${encodedBody} >> /tmp/send.AMQP.${jobid}.history.txt 
    254         sendAMQPMsg -h localhost -p 5672 -b ${encodedBody} 
    255         status=$? 
    256         if [ ${status} -gt 0 ] ; then 
    257           IGCM_debug_Print 2 "IGCM_debug_PopStack : command sendAMQPMsg failed error code ${status}" 
    258           echo  sendAMQPMsg -h localhost -p 5672 -b "${Body}" 
    259           exit 
    260         fi 
     355        # Fill the rabbitMQ queue 
     356        IGCM_debug_sendAMQP 
    261357      fi 
    262  
    263       # TO BE A FUNCTION END # 
    264  
    265     fi 
    266  
     358    fi 
     359 
     360    # Reset array if necessary 
    267361    if [ ${IGCM_debug_LenStack} = 0 ]; then 
    268       # Reset array only when necessary 
    269362      #echo 
    270363      #IGCM_debug_Print 3 "Clean stack array" 
    271364      #echo 
    272       #set -A IGCM_debug_Stack ${NULL_STR} 
    273       #set -A IGCM_debug_StackArgs ${NULL_STR} 
    274365      unset IGCM_debug_Stack 
    275366      unset IGCM_debug_StackArgs 
     367      unset IGCM_debug_StackTiming 
    276368      IGCM_debug_Stack[0]=${NULL_STR} 
    277369      IGCM_debug_StackArgs[0]=${NULL_STR} 
     370      IGCM_debug_StackTiming[0]=${NULL_STR} 
    278371    fi 
    279372  fi 
     
    288381  IGCM_debug_PushStack "IGCM_debug_ActivateBigBro" 
    289382 
    290   # Fill the rabbitMQ queue 
    291383  if [ X${BigBrother} = Xtrue ] ; then 
    292384    # ID to identify a simulation 
    293385    simuid=${config_UserChoices_JobName}.${config_UserChoices_ExperimentName}.${config_UserChoices_SpaceName}.${config_UserChoices_TagName}.p86denv.TGCC.CURIE 
     386 
    294387    # ID to identify a job. Several Jobs are needed to complete a simulation 
    295388    jobid=${config_UserChoices_JobName}.${config_UserChoices_ExperimentName}.${config_UserChoices_SpaceName}.${config_UserChoices_TagName}.p86denv.TGCC.CURIE.${CumulPeriod} 
    296     # Only cosmetics 
    297     decal=0 
    298     while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do 
    299       printf ' ' >> ${StackFileLocation}/stack 
    300       (( decal = decal + 1 )) 
    301     done 
    302     # RabbitMQ message 
     389 
     390    # RabbitMQ message code 
    303391    if ( ${FirstInitialize} ) ; then 
    304392      code=0000 
     
    306394      code=1000 
    307395    fi 
     396    # RabbitMQ message body 
    308397    Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"OK\",\"out\":\"false\",\"nesting\":\"${IGCM_debug_LenStack}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" ) 
    309     encodedBody=$( echo "${Body}" | base64 -w 0 ) 
    310     # 
    311     cat ${SUBMIT_DIR}/config.card | base64 -w 0 > ${SUBMIT_DIR}/config.card.base64 
    312     # 
    313     echo sendAMQPMsg -h localhost -p 5672 -f ${SUBMIT_DIR}/config.card.base64 -b "${Body}"      >> ${StackFileLocation}/stack 
    314     echo sendAMQPMsg -h localhost -p 5672 -f ${SUBMIT_DIR}/config.card.base64 -b ${encodedBody} >> /tmp/send.AMQP.${jobid}.history.txt 
    315     sendAMQPMsg -h localhost -p 5672 -f ${SUBMIT_DIR}/config.card.base64 -b ${encodedBody} 
    316     status=$? 
    317     if [ ${status} -gt 0 ] ; then 
    318       IGCM_debug_Print 2 "IGCM_debug_ActivateBigBro : command failed error code ${status}" 
    319       echo  sendAMQPMsg -h localhost -p 5672 -b "${Body}" 
    320       IGCM_debug_Exit "IGCM_debug_ActivateBigBro" 
    321     fi 
     398    # Fill the rabbitMQ queue (specifying config.card must be send) 
     399    IGCM_debug_sendAMQP activate 
     400 
     401    # Turn the flag on 
    322402    ActivateBigBro=true 
    323403  fi 
     
    332412  IGCM_debug_PushStack "IGCM_debug_Exit" 
    333413  echo "IGCM_debug_Exit : " "${@}" 
    334   echo  
     414  echo 
    335415  echo "!!!!!!!!!!!!!!!!!!!!!!!!!!" 
    336   echo "!!   ERROR TRIGGERED    !!"  
    337   echo "!!   EXIT FLAG SET      !!"  
    338   echo "!------------------------!"  
    339   echo  
     416  echo "!!   ERROR TRIGGERED    !!" 
     417  echo "!!   EXIT FLAG SET      !!" 
     418  echo "!------------------------!" 
     419  echo 
    340420  IGCM_debug_CallStack 
    341421  ExitFlag=true 
     
    358438      IGCM_debug_CallStack 
    359439    fi 
     440 
     441    if [ X${ActivateBigBro} = Xtrue ] ; then 
     442      # RabbitMQ message code 
     443      code=9999 
     444      # RabbitMQ message body 
     445      Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"FATAL\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" ) 
     446      # Fill the rabbitMQ queue 
     447      IGCM_debug_sendAMQP 
     448    fi 
     449 
     450    # Not sure about that one ... 
    360451    if ( $DEBUG_debug ) ; then 
    361452      echo "Your files on ${R_OUT} :" 
     
    364455    fi 
    365456 
    366     # TO BE A FUNCTION BEGIN # 
    367  
    368     if [ X${ActivateBigBro} = Xtrue ] ; then 
    369       # Only cosmetics 
    370       decal=0 
    371       while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do 
    372         printf ' ' >> ${StackFileLocation}/stack 
    373         (( decal = decal + 1 )) 
    374       done 
    375       # RabbitMQ message 
    376       code=9999 
    377       # 
    378       Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"FATAL\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" ) 
    379       encodedBody=$( echo "${Body}" | base64 -w 0 ) 
    380       # 
    381       echo sendAMQPMsg -h localhost -p 5672 -b "${Body}"      >> ${StackFileLocation}/stack 
    382       echo sendAMQPMsg -h localhost -p 5672 -b ${encodedBody} >> /tmp/send.AMQP.${jobid}.history.txt 
    383       sendAMQPMsg -h localhost -p 5672 -b ${encodedBody} 
    384       status=$? 
    385       if [ ${status} -gt 0 ] ; then 
    386         IGCM_debug_Print 2 "IGCM_debug_PopStack : command sendAMQPMsg failed error code ${status}" 
    387         echo  sendAMQPMsg -h localhost -p 5672 -b "${Body}" 
    388         exit 
    389       fi 
    390     fi 
    391  
    392     # TO BE A FUNCTION END # 
    393  
    394457    # Mail notification 
    395458    IGCM_sys_SendMail 
     459 
    396460    # And Good Bye 
    397461    date 
     
    448512    1) for i in "$@" ; do 
    449513      ${cmd_echo} $(date +"%Y-%m-%d %T") "--Debug1-->" ${i} 
    450       done ;;  
     514      done ;; 
    451515    2) for i in "$@" ; do 
    452516      ${cmd_echo} $(date +"%Y-%m-%d %T") "--------Debug2-->" ${i} 
    453       done ;;  
     517      done ;; 
    454518    3) for i in "$@" ; do 
    455519      ${cmd_echo} $(date +"%Y-%m-%d %T") "--------------Debug3-->" ${i} 
    456       done ;;  
     520      done ;; 
    457521    esac 
    458522  fi 
     
    473537    IGCM_debug_Print ${level} ${list} 
    474538  fi 
     539} 
     540 
     541#D-#================================================================== 
     542#D-function IGCM_debug_PrintInfosAction 
     543#D-* Purpose: Print information related to instrumentation 
     544function IGCM_debug_PrintInfosActions 
     545{ 
     546  typeset actionType=$1 
     547  typeset entitySize=$2 
     548  typeset start_ms=$3 
     549  typeset end_ms=$4 
     550 
     551  typeset dest=$5 
     552  typeset source=$6 
     553 
     554  typeset diff_ms entitySizeKo entitySizeMo flux_Ko_ms flux_Ko_s flux_Mo_s 
     555  typeset name dirOut dirSource 
     556 
     557  name="doNotKnow" 
     558 
     559  diff_ms=$(( $end_ms - $start_ms )) 
     560  # echo "diff_ms=$diff_ms" 
     561 
     562  entitySizeKo=$( echo ${entitySize} | gawk -F"|" '{print $1}' ) 
     563  # echo "entitySizeKo=$entitySizeKo" 
     564  entitySizeMo=$( echo ${entitySize} | gawk -F"|" '{print $2}' ) 
     565 
     566  # flux en Ko / ms 
     567  flux_Ko_ms=$( echo "scale=6;${entitySizeKo}/${diff_ms}" | bc ) 
     568  # echo "flux_Ko_ms=$flux_Ko_ms" 
     569 
     570  # flux en Ko / s 
     571  flux_Ko_s=$(( $flux_Ko_ms * 1000 )) 
     572  # echo "flux_Ko_s=$flux_Ko_s" 
     573 
     574  # flux en Mo / s 
     575  flux_Mo_s=$( echo "scale=6;${flux_Ko_s}/1024" | bc ) 
     576  # echo "flux_Mo_s=$flux_Mo_s" 
     577 
     578  if [ -d $dest ] ; then 
     579    dirOut=$( readlink -f ${dest} ) 
     580  else 
     581    dirOut=$( readlink -f $( dirname ${dest} ) ) 
     582  fi 
     583 
     584  if [ -d $source ] ; then 
     585    dirSource=$( readlink -f ${source} ) 
     586  else 
     587    dirSource=$( readlink -f $( dirname ${source} ) 
     588  fi 
     589 
     590  echo "==>act:${actionType}|sz:${entitySizeMo}|ms:${diff_ms}|fx(ko):${flux_Ko_s}|fx(mo):${flux_Mo_s}|nm:${name}|dirSource:${dirSource}|dirOut:${dirOut}" 
    475591} 
    476592 
Note: See TracChangeset for help on using the changeset viewer.