TO INVENTORY APPS BOUND TO SERVICE REGISTRYLogin to the cf CLI with admin level permissions. The following scripts can be run on any UNIX-like, bash-capable system which has cf CLI and jq installed and which has network access to the Tanzu environment.
#!/bin/sh
#
# cf login -a api.system-domain using UAA admin credentials before executing this script
# must have jq executable in $PATH
#
DATE=`date`
echo "Service Instance Env Variables - $DATE"
echo "============================================================="
export ORG='p-spring-cloud-services'
cf t -o $ORG
cf spaces |
while read SPACE
do
STR_LENGTH=`echo $SPACE | wc -c`
if [ $STR_LENGTH -eq 37 ]
then
echo "============================"
SI_CURL=`cf curl /v2/service_instances/$SPACE`
SERVICE_NAME=`echo $SI_CURL | jq '.entity.name'`
SPACE_URL=`echo $SI_CURL | jq '.entity.space_url' | sed -e 's/^"//' -e 's/"$//' `
SPACE_CURL=`cf curl $SPACE_URL`
ORG_URL=`echo $SPACE_CURL| jq '.entity.organization_url' | sed -e 's/^"//' -e 's/"$//' `
echo "ORG_URL -- $ORG_URL"
ORG_CURL=`cf curl $ORG_URL`
SPACE_NAME=`echo $SPACE_CURL | jq '.entity.name'`
ORG_NAME=`echo $ORG_CURL | jq '.entity.name'`
if [[ $SI_CURL =~ "service-registry" ]]
then
cf t -s $SPACE
echo "-------------------"
echo "SI GUID -- $SPACE"
echo "SERVICE NAME - $SERVICE_NAME"
echo "SPACE - $SPACE_NAME"
echo "ORG - $ORG_NAME"
cf apps |
while read APP
do
if [[ $APP =~ "service-registry" ]]
then
echo ""
REGISTRY_APP=`echo $APP | cut -d " " -f1`
REGISTRY_GUID=`cf app $REGISTRY_APP --guid`
REGISTRY_CURL=`cf curl /v2/apps/$REGISTRY_GUID/env`
ENV_JSON=`echo $REGISTRY_CURL | jq '.environment_json'`
echo "$ENV_JSON"
fi
done
fi
fi
done
TO INVENTORY STATUS OF LAST OPERATION FOR EACH CONFIG SERVER
#!/bin/sh
#
# cf login -a api.system-domain using UAA admin credentials before executing this script
# must have jq executable in $PATH
#
DATE=`date`
echo "Status of Last Operation for All Config Servers - $DATE"
echo "============================================================="
export ORG='p-spring-cloud-services'
cf t -o $ORG
cf spaces |
while read SPACE
do
STR_LENGTH=`echo $SPACE | wc -c`
if [ $STR_LENGTH -eq 37 ]
then
cf t -s $SPACE
echo "-------------------"
echo "SI GUID -- $SPACE"
cf apps |
while read APP
do
if [[ $APP =~ "config" ]]
then
echo ""
CS_APP=`echo $APP | cut -d" " -f1`
CS_GUID=`cf app $CS_APP --guid`
CS_LAST_STATE=`cf curl /v2/service_instances/$SPACE | jq '.entity.last_operation.state'`
CS_UPDATE_TIME=`cf curl /v2/service_instances/$SPACE | jq '.entity.last_operation.updated_at'`
echo "ORG $ORG - SPACE $SPACE - CONFIG SERVER $CS_APP"
echo "TIMESTAMP $CS_UPDATE_TIME - STATE $CS_LAST_STATE"
fi
done
fi
done