Spring Cloud Services Instance Status Report
search cancel

Spring Cloud Services Instance Status Report

book

Article ID: 391115

calendar_today

Updated On:

Products

VMware Tanzu Application Service

Issue/Introduction

Before upgraded the ALL (or individually) SCS service instances it it recommended to verify ALl service instances to be in a good state. Cleanup any failed instances.

The script provides a report of the following fields. 

  • SI GUID
  • SERVICE NAME
  • SPACE
  • ORG
  • STATUS
  • DASHBOARD_URL
  • ROUTES


Sample output:

$ /tmp/scs_si_state.sh
=============================================================
Spring Cloud Services Instances  - Wed Mar 19 06:53:47 MDT 2025
-------------------
SI GUID -- 1111111-2222-3333-55555555
SERVICE NAME - "myservice-registry"
SPACE        - "myspace"
ORG          - "bsamson"
STATUS       - "failed"
DASHBOARD_URL- "https://service-registry-1111111-2222-3333-55555555.apps-example.com/dashboard"
Routes       - service-registry-1111111-2222-3333-55555555.example.com
-------------------
SI GUID -- 1111111-2222-3333-444444444
SERVICE NAME - "myconfig"
SPACE        - "myspace"
ORG          - "myorg"
STATUS       - "succeeded"
DASHBOARD_URL- "https://config-server-1111111-2222-3333-444444444.apps-example.com/dashboard"
Routes       - config-server-1111111-2222-3333-444444444.apps.example.com

 

The report can be used to:

  • Identify failed service instances.
  • Identify the service instance name and location (org/space) 
  • Identify problem with unmatched dashboard_url and route.

 

 

Environment

  • Tanzu Platform for Cloud Foundry
  • Spring Cloud Services for TPCF

Resolution

  1. Create the script by copy and paste. 
    • cat <<'EOF' > /tmp/scs_si_state.sh
      #!/bin/sh
      # PREREQUISITES
      # - User must be logged in with UAA admin credentials before executing this script.
      # cf login -a api.system-domain
      #
      DATE=`date`
      echo "============================================================="
      echo "Spring Cloud Services Instances  - $DATE"
      #echo "============================================================="
      export ORG='p-spring-cloud-services'
      cf t -o $ORG > /dev/null 2>&1
      cf spaces |
      while read SPACE
      do
        STR_LENGTH=`echo $SPACE | wc -c`
        if [ $STR_LENGTH -eq 37 ]
        then
          SI_CURL=`cf curl /v2/service_instances/$SPACE`
          SERVICE_NAME=`echo $SI_CURL | jq '.entity.name'`
          LAST_OPERATION_STATUS=`echo $SI_CURL | jq '.entity.last_operation.state'`
          DASHBOARD_URL=`echo $SI_CURL | jq '.entity.dashboard_url'`
      
      
          SPACE_URL=`echo $SI_CURL | jq '.entity.space_url' | sed -e 's/^"//' -e 's/"$//' `
          # echo "SPACE_URL -- $SPACE_URL"
      
          SPACE_CURL=`cf curl $SPACE_URL`
          # echo "ORG-CURL -- $SPACE_CURL"
          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'`
      
          #echo "============================"
          cf t -s $SPACE > /dev/null 2>&1
          echo "-------------------"
          echo "SI GUID -- $SPACE"
          echo "SERVICE NAME - $SERVICE_NAME"
          echo "SPACE        - $SPACE_NAME"
          echo "ORG          - $ORG_NAME"
          echo "STATUS       - $LAST_OPERATION_STATUS"
          echo "DASHBOARD_URL- $DASHBOARD_URL"
          cf apps |
          while read APP
          do
            if [[ $APP =~ "config-server" ]] || [[ $APP =~ "service-registry" ]]
            then
              ROUTE=`echo $APP | cut -d" " -f4`
              echo "Routes       - $ROUTE"
            fi
          done
        fi
      done
      
      EOF
  2. make it executable
    • chmod +x /tmp/scs_si_state.sh
  3. Run the script
    • /tmp/scs_si_state.sh