Skip to content

Instantly share code, notes, and snippets.

@charlesmarshall
Created September 17, 2014 09:58
Show Gist options
  • Save charlesmarshall/cd192ff17a7bf61db8bd to your computer and use it in GitHub Desktop.
Save charlesmarshall/cd192ff17a7bf61db8bd to your computer and use it in GitHub Desktop.
Simple script to parse out deis info data from a set of sub directories
#!/bin/bash
oldIFS=$IFS
IFS="
"
DIR=$1
printf "\n\n%-25s %-15s %10s %17s\n" "REPO" "DEIS NAME" "STATUS" "IP"
echo "======================================================================="
for d in $(find $DIR -maxdepth 1 -type d | sort ); do
if [[ "${d}" == "$DIR" ]]; then
echo ""
else
cd $d 1> /dev/null
deis_name=$(deis info | grep "=== .* Application" -o | sed -r 's#Application| |=##gi')
repo=$(echo $d | sed -r 's#$DIR##gi' | sed -r 's#./##gi')
location=""
stat=""
if [[ ! -z $deis_name ]]; then
location=$(fleetctl list-units | grep "${deis_name}_.*\.web\.[0-9]\.service" -m1 | awk ' { print $2 } ' | sed -E 's#.*/##i')
stat=$(fleetctl list-units | grep "${deis_name}_.*\.web\.[0-9]\.service" -m1 | awk ' { print $3 } ')
fi
printf "%-25s %15s %10s %17s\n" "${repo}" "${deis_name}" "${stat}" "${location}"
#echo "${repo} -> ${deis_name} -> ${location}"
cd - 1> /dev/null
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment