Skip to content

Instantly share code, notes, and snippets.

@cprice404
Created September 13, 2012 00:18
Show Gist options
  • Save cprice404/3710938 to your computer and use it in GitHub Desktop.
Save cprice404/3710938 to your computer and use it in GitHub Desktop.
puppetdb over ssl
host, port = args
puts "Hi there"
Puppet.notice("HI from logging!!!")
require 'puppet/network/http_pool'
path = "/metrics/mbean/java.lang:type=Memory"
headers = { "Accept" => "application/json" }
Puppet.notice("HI from logging2!!!")
conn = Puppet::Network::HttpPool.http_instance(host, port, true)
Puppet.notice("HI from logging3!!!")
begin
response = conn.get(path, headers)
rescue => e
Puppet.notice("HI from logging 3.5 (e: #{e.inspect}, #{e})")
end
Puppet.notice("HI from logging4!!!")
unless response.kind_of?(Net::HTTPSuccess)
Puppet.notice("HI from logging5!!!")
Puppet.err "Unable to connect to puppetdb server (#{host}:#{port}): [#{response.code}] #{response.msg}"
return false
end
Puppet.notice("HI from logging6!!!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment