Created
October 12, 2016 16:45
-
-
Save saliceti/773e09335042ad4ad7841d6944878fa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'loggregator_emitter' | |
require 'net/http' | |
require 'json' | |
nats_ip = '10.0.16.11' | |
nats_monitor_port = 4333 | |
metron_port = 3457 | |
@http = Net::HTTP.new(nats_ip, nats_monitor_port) | |
@get_varz = Net::HTTP::Get.new('/varz') | |
@emitter = LoggregatorEmitter::Emitter.new("127.0.0.1:#{metron_port}", 'origin', 'NAT') | |
def emit_metric(name, value) | |
puts "Emitting metric cf.origin.#{name} = #{value}" | |
@emitter.emit_value_metric(name, value, '') | |
end | |
while true do | |
response = @http.request(@get_varz) | |
stats = JSON.load(response.body) | |
emit_metric 'colin.nats.in_msgs', stats['in_msgs'] | |
emit_metric 'colin.nats.out_msgs', stats['out_msgs'] | |
emit_metric 'colin.nats.connections', stats['connections'] | |
sleep(5) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment