#!/bin/bash # This script will: # 1. Gather and create a unique list of "Task Definition Version ID"s on a client; # 2. Gather the "Task execution instance ID"s for each version id from the above list; # 3. Gather task execution information task Version and instance ID. # Function to detect task and instance guids by finding a leading bracket id_has_bracket(){ bracket_check=`echo $curr_id | cut -c1` # echo "bracket_check=$bracket_check; $curr_id" if [ "$bracket_check" = "{" ]; then # echo " returning true" return $TRUE else # echo " returning false" return $FALSE fi } ############################################################################## ##### Get list of all "Task Definition Version ID"s on the client machine #### ############################################################################## i=0 cta_list_results=`aex-cta list --show-task-id` while read task_dt task_tm task_status task_id task_name junk do curr_id="$task_id" if ( id_has_bracket $curr_id ); then idlist[$i]=$task_id ((i++)) fi done < <(echo "$cta_list_results") tasklist=`printf '%s\n' "${idlist[@]}" | sort -u` if [ "$tasklist" == "" ]; then echo "No tasks" exit fi ############################################################################# ##### Get list of all "Task execution instance ID"s on the client machine #### ############################################################################## i=0 for taskid in $tasklist; do cta_list2_results=`aex-cta list $taskid` while read instance_dt instance_tm instance_status instance_id do curr_id="$instance_id" if ( id_has_bracket $curr_id ); then combined="$taskid $instance_id" instance_list[$i]=$combined ((i++)) fi done < <(echo "$cta_list2_results") done # This list should already have unique entries, so the "sort -u" isn't needed, imho. combined_list=`printf '%s\n' "${instance_list[@]}"` ############################################################################## ##### Get additional information for each task and instance #### ############################################################################## while read taskid instance_id; do # The task name isn't in the summary info so this command has to be ran twice task_name=`aex-cta info $taskid $instance_id --name` summary=`aex-cta info $taskid $instance_id --summary` status=`echo "$summary" | grep "Status " | awk '{ print $2 }'` start_time=`echo "$summary" | grep "Start time" | awk '{ print $3 " " $4 }'` # output the desired data. printf might also be used for formatting columns, etc. echo $start_time $taskid $instance_id \"$task_name\" " - " $status done < <(echo "$combined_list")