Verifying Cloud Foundry Routes

Occasionally you may run into an issue where the routes between the routers and nats are not in a consistent state. To detect this issue log onto a server with connectivity to your BOSH director and copy the following Bash script onto it:

#!/usr/bin/env bash
DEPLOYMENT=$1
RUSER=$2
RPASSWORD=$3
if [[ -z ${DEPLOYMENT} ]]; then
  echo "No deployment specified."
  exit 1
fi
if [[ -z ${RUSER} ]]; then
  echo "No router user specified"
  exit 1
fi
if [[ -z ${RPASSWORD} ]]; then
  echo "No router user password specified"
  exit 1
fi
if ! [ -x "$(command -v jq)" ]; then
  echo 'jq is not installed and is requried - please install' >&2
  exit 2
fi
for ip in $(bosh vms $DEPLOYMENT| grep router_z | grep -oE "[0-9]+\..*[0-9]+"); do
  echo Router IP Address: $ip
  temp_length=$(curl -s http://$RUSER:[email protected]$ip:8080/routes | jq length)
  echo Router Routes length: $temp_length
  temp_length=
done

To use this script you will need to retrieve the router username and password from your deployment manifest and call the script with the following parameters:

script <deployment name> <router.status.user> <router.status.password>

This will generate output similar to:

Router IP Address: 10.8.8.100
Router Routes length: 12121
Router IP Address: 10.8.8.101
Router Routes length: 12121
Router IP Address: 10.8.8.102
Router Routes length: 4336

If there are inconsistencies you likely just need to monit restart on all of the nats servers.

Spread the word

twitter icon facebook icon linkedin icon