Skip to content

Instantly share code, notes, and snippets.

@teddyking
Created May 26, 2014 07:57
Show Gist options
  • Save teddyking/613cec7d81e0db1b02e6 to your computer and use it in GitHub Desktop.
Save teddyking/613cec7d81e0db1b02e6 to your computer and use it in GitHub Desktop.
Prints out the /healthz and /varz connection info for running Cloud Foundry jobs.
# This script prints out the /healthz and /varz connection info
# for your running Cloud Foundry jobs.
#
# The nats_uri variable should be updated to suit your deployment.
# The default nats_uri value will work for a standard bosh-lite deployment.
require 'json'
require 'nats/client'
nats_uri = 'nats://nats:nats@10.244.0.6:4222'
NATS.start(:uri => nats_uri) do
NATS.request('vcap.component.discover') do |json_msg|
h = JSON.parse(json_msg)
puts "Component: #{h['type']}/#{h['index']}"
puts "Host: #{h['host']}"
puts "Username: #{h['credentials'][0]}"
puts "Password: #{h['credentials'][1]}"
puts "curl -u #{h['credentials'][0]}:#{h['credentials'][1]} #{h['host']}/healthz"
puts "curl -u #{h['credentials'][0]}:#{h['credentials'][1]} #{h['host']}/varz"
puts ""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment