Skip to content

Instantly share code, notes, and snippets.

@benders
Created October 19, 2013 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benders/7052459 to your computer and use it in GitHub Desktop.
Save benders/7052459 to your computer and use it in GitHub Desktop.
Get some New Relic on a Puppet Master server (version 2.7)
# Oh ho ho, let's see if we can have some fun with the Ruby Agent - Nic 2013-10-18
require 'rubygems'
require 'newrelic_rpm'
require 'new_relic/agent/instrumentation/rack'
# END monkey-business
# A "config.ru", for use with every Rack-compatible webserver.
# SSL needs to be handled outside this, though.
$0 = "master"
# If you want debugging, uncomment the following line:
# ARGV << "--debug"
ARGV += ["--rack"]
require "puppet/application/master"
class Puppet::Application::Master
unless defined?(setup_original) then
alias :setup_original :setup
end
def setup
result = setup_original
# This must run after the original setup method because we depend on it
# completing all our setup steps to be able to call these next methods...
if Puppet::SSL::CertificateAuthority.ca? then
begin
require "puppet/util/license"
Puppet::Util::License.display_license_status
rescue Exception => e
Puppet.crit("Loading the license code in the master failed:\n#{e}")
Puppet.crit("Something is very wrong with your install; please reinstall\n" +
"or otherwise contact Puppet Labs for support!")
# ...and that is sufficient. --daniel 2011-01-18
end
end
result
end
end
# More New Relic experimentation - Nic 2013-10-18
# Puppet::Application[:master].main.class_eval do
require 'puppet/network'
require 'puppet/network/http/rack'
Puppet::Network::HTTP::Rack.class_eval do
include ::NewRelic::Agent::Instrumentation::Rack
end
# END extra crap
run Puppet::Application[:master].run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment