Agnus Dei (jackal) wrote,
Agnus Dei
jackal

Using standard arrays in bash (Example)

Example of using standard arrays on bash.

# ELB's to check
ELBARRAY[0]="AAAA-ELB"     # dev
ELBARRAY[1]="BBBB-ELB"    #
ELBARRAY[2]="CCCC-ELB"    #

#Matching regions to the above
REGION[0]="us-east-1"
REGION[1]="us-west-1"
REGION[2]="us-east-1"

#CRITICAL LIMIT - Set to -1 for dev servers so they can't alarm critical
CRITLIMIT[0]="-1"  # dev ELB
CRITLIMIT[1]="0"
CRITLIMIT[2]="0"

     
# Test for each ELB
INDEX=0
for foofoo in "${ELBARRAY[@]}"
do   
    RESULTS=`/usr/local/bin/check_elb_health.sh -r ${REGION[$INDEX]} -c ${CRITLIMIT[$INDEX]}  ${ELBARRAY[$INDEX]}`
    RETURNCODE=$?
    # RETURNCODE=2  # set for debugging
    track_worst_result $RETURNCODE  # external function

    # Capture the results for any bad checks
    if [[ "$RETURNCODE" -gt "0" ]]; then
        FINALRESULTS="$RESULTS $FINALRESULTS"
    fi
    ((INDEX=INDEX+1))
done
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments