newrelic_ia 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +4 -0
- data/LICENSE +22 -0
- data/README.rdoc +101 -38
- data/Rakefile +87 -43
- data/bin/newrelic_ia +11 -3
- data/lib/new_relic/ia/cli.rb +136 -83
- data/lib/new_relic/ia/memcached_sampler.rb +340 -0
- data/lib/new_relic/ia/metric_names.rb +2 -2
- data/lib/new_relic/ia/newrelic.yml +17 -8
- data/lib/new_relic/ia/version.rb +5 -0
- data/lib/newrelic_ia.rb +5 -8
- data/spec/cli_spec.rb +6 -0
- data/spec/memcached-1.out +24 -0
- data/spec/memcached-nodes.txt +4 -0
- data/spec/memcached_sampler_spec.rb +58 -0
- data/spec/spec_helper.rb +4 -2
- metadata +49 -35
- data/Manifest +0 -21
- data/newrelic_ia.gemspec +0 -41
data/CHANGELOG
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2009-2010 New Relic, Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,23 +1,17 @@
|
|
1
1
|
= New Relic Infrastructure Agent
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
This is a work in progress. We hope to add more statistics
|
7
|
-
to the agent as well as more useful views on the RPM site
|
8
|
-
for viewing these metrics.
|
9
|
-
|
10
|
-
== DESCRIPTION:
|
3
|
+
Gem for collecting memcached, disk, cpu and IO statistics. Collected
|
4
|
+
stats are sent to the New Relic RPM application.
|
11
5
|
|
12
6
|
Use this gem to collect statistics from a given host by running
|
13
7
|
newrelic_ia -a as a daemon. This will contribute System/* metrics
|
14
8
|
to your RPM console which can be viewed with custom dashboards.
|
15
9
|
|
16
|
-
==
|
10
|
+
== Synopsis
|
17
11
|
|
18
12
|
newrelic_ia [ options ] aspect, aspect..
|
19
13
|
|
20
|
-
aspect: one or more of 'iostat' or 'disk' (more to come)
|
14
|
+
aspect: one or more of 'iostat' or 'disk' or 'memcached' (more to come)
|
21
15
|
|
22
16
|
-a, --all use all available aspects
|
23
17
|
-v, --verbose debug output
|
@@ -26,15 +20,14 @@ to your RPM console which can be viewed with custom dashboards.
|
|
26
20
|
--install create a default newrelic.yml
|
27
21
|
-h, --help Show this help message.
|
28
22
|
|
29
|
-
==
|
23
|
+
== Requirements
|
30
24
|
|
31
|
-
* New Relic Agent version 2.
|
25
|
+
* New Relic Agent version 2.10.6 or later
|
32
26
|
* Gold Subscription for creating and viewing custom dashboards
|
33
27
|
|
34
|
-
==
|
28
|
+
== Install
|
35
29
|
|
36
|
-
sudo gem
|
37
|
-
sudo gem install newrelic-ia
|
30
|
+
sudo gem install newrelic_ia
|
38
31
|
|
39
32
|
Once installed, run from the home directory of your Rails
|
40
33
|
application, or create a separate working directory and run
|
@@ -44,27 +37,97 @@ application, or create a separate working directory and run
|
|
44
37
|
to create a template newrelic.yml file you can use. Edit this file
|
45
38
|
and substitute your license key and app_name value.
|
46
39
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
40
|
+
specify memcached nodes in memcached-nodes.txt.
|
41
|
+
|
42
|
+
== Credits
|
43
|
+
|
44
|
+
Special thanks to Chandra Patni and Tony Ford of IGN for the Memcached
|
45
|
+
sampler.
|
46
|
+
|
47
|
+
== Memcached Details
|
48
|
+
|
49
|
+
Memcached statistics sampler collects subset of stats provided by
|
50
|
+
memcached daemon, once a minute. In addition it computes other stats
|
51
|
+
dervied from memcached stats. Also support stats derivatives over time
|
52
|
+
to compute rate etc. Specify Memcached nodes configuration in the
|
53
|
+
newrelic.yml file.
|
54
|
+
|
55
|
+
Memcached stats are reported for each node and also sample reports aggregated stats
|
56
|
+
|
57
|
+
=== Stats Detail
|
58
|
+
|
59
|
+
uptime Number of seconds this server has been running
|
60
|
+
curr_items Current number of items stored by the server
|
61
|
+
total_items Total number of items stored by this server
|
62
|
+
ever since it started
|
63
|
+
bytes Current number of bytes used by this server to store items
|
64
|
+
curr_connections Number of open connections
|
65
|
+
total_connections Total number of connections opened since
|
66
|
+
the server started running
|
67
|
+
connection_structures Number of connection structures allocated by the server
|
68
|
+
cmd_get Cumulative number of retrieval requests
|
69
|
+
cmd_set Cumulative number of storage requests
|
70
|
+
get_hits Number of keys that have been requested and found present
|
71
|
+
get_misses Number of items that have been requested and not found
|
72
|
+
evictions Number of valid items removed from cache to free
|
73
|
+
memory for new items
|
74
|
+
bytes_read Total number of bytes read by this server from network
|
75
|
+
bytes_written Total number of bytes sent by this server to network
|
76
|
+
limit_maxbytes Number of bytes this server is allowed to use for storage
|
77
|
+
threads Number of worker threads requested
|
78
|
+
|
79
|
+
Derived Stats (computed stats):
|
80
|
+
|
81
|
+
free_maxbytes Number of free bytes this server has available for storage
|
82
|
+
|
83
|
+
Stats Derivatives (time derivatives of stats):
|
84
|
+
|
85
|
+
hit_ratio Percent of keys that have been requested and found present
|
86
|
+
miss_ratio Percent of keys that have been requested and found missing
|
87
|
+
rpm Requests per minutes
|
88
|
+
gpm Gets per minutes
|
89
|
+
hpm Hits per minutes
|
90
|
+
mpm Misses per minutes
|
91
|
+
spm Sets per minutes
|
92
|
+
fpm Flushes per minutes
|
93
|
+
epm Evictions per minutes
|
94
|
+
|
95
|
+
|
96
|
+
=== Sample Custom View
|
97
|
+
|
98
|
+
Liquid template for NewRelic custom dashboard:
|
99
|
+
|
100
|
+
<div>
|
101
|
+
<div style="float: left; width: 50%;">
|
102
|
+
{% line_chart value:average_value title:'Cache Miss Ratio' metric:'System/Memcached/Miss Ratio' simple_tooltip:true label:segment_3 value_suffix:'%' %}
|
103
|
+
</div>
|
104
|
+
<div style="float: left; width: 50%;">
|
105
|
+
{% line_chart value:average_value title:'Cache Memory' regexp:'System/Memcached/(Bytes|Free Bytes|Limit Maxbytes)' simple_tooltip:true label:segment_3 %}
|
106
|
+
</div>
|
107
|
+
<br style="clear: both" />
|
108
|
+
</div>
|
109
|
+
|
110
|
+
<div style="padding-top: 20px"> </div>
|
111
|
+
|
112
|
+
<div>
|
113
|
+
<div style="float: left; width: 50%;">
|
114
|
+
{% line_chart value:average_value title:'Cache Gets & Sets' regexp:'System/Memcached/(Gpm|Spm)' simple_tooltip:true label:segment_3 %}
|
115
|
+
</div>
|
116
|
+
<div style="float: left; width: 50%;">
|
117
|
+
{% line_chart value:average_value title:'Cache Misses, Flushes, & Evictions' regexp:'System/Memcached/(Mpm|Epm|Fpm)' simple_tooltip:true label:segment_3 %}
|
118
|
+
</div>
|
119
|
+
<br style="clear: both" />
|
120
|
+
</div>
|
121
|
+
|
122
|
+
<div style="padding-top: 20px"> </div>
|
123
|
+
|
124
|
+
<div>
|
125
|
+
<div style="float: left; width: 50%;">
|
126
|
+
{% line_chart value:average_value title:'Active Connections' metric:'System/Memcached/Curr Connections' simple_tooltip:true hide_legend:true %}
|
127
|
+
</div>
|
128
|
+
<div style="float: left; width: 50%;">
|
129
|
+
{% line_chart value:average_value title:'Cache Objects' metric:'System/Memcached/Curr Items' simple_tooltip:true hide_legend:true %}
|
130
|
+
</div>
|
131
|
+
<br style="clear: both" />
|
132
|
+
</div>
|
63
133
|
|
64
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
65
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
66
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
67
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
68
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
69
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
70
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,43 +1,87 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require '
|
3
|
-
|
4
|
-
require
|
5
|
-
|
6
|
-
GEM_NAME = "newrelic_ia"
|
7
|
-
GEM_VERSION = NewRelic::IA::VERSION
|
8
|
-
AUTHOR = "Bill Kayser"
|
9
|
-
EMAIL = "bkayser@newrelic.com"
|
10
|
-
HOMEPAGE = "http://www.newrelic.com"
|
11
|
-
SUMMARY = "New Relic Gem for gathering system metrics"
|
12
|
-
DESCRIPTION = <<EOF
|
13
|
-
The New Relic Infrastructure Agent (IA) collects system metrics and transmits
|
14
|
-
them to the RPM server where they can be viewed with custom dashboards.
|
15
|
-
EOF
|
16
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require File.dirname(__FILE__) + '/lib/new_relic/ia/version.rb'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
GEM_NAME = "newrelic_ia"
|
7
|
+
GEM_VERSION = NewRelic::IA::VERSION
|
8
|
+
AUTHOR = "Bill Kayser"
|
9
|
+
EMAIL = "bkayser@newrelic.com"
|
10
|
+
HOMEPAGE = "http://www.newrelic.com"
|
11
|
+
SUMMARY = "New Relic Gem for gathering system metrics"
|
12
|
+
DESCRIPTION = <<EOF
|
13
|
+
The New Relic Infrastructure Agent (IA) collects system metrics and transmits
|
14
|
+
them to the RPM server where they can be viewed with custom dashboards.
|
15
|
+
EOF
|
16
|
+
|
17
|
+
# See http://www.rubygems.org/read/chapter/20
|
18
|
+
begin
|
19
|
+
require 'jeweler'
|
20
|
+
Jeweler::Tasks.new do |gem|
|
21
|
+
gem.name = GEM_NAME
|
22
|
+
gem.summary = SUMMARY
|
23
|
+
gem.description = DESCRIPTION
|
24
|
+
gem.email = EMAIL
|
25
|
+
gem.homepage = HOMEPAGE
|
26
|
+
gem.author = AUTHOR
|
27
|
+
gem.version = GEM_VERSION
|
28
|
+
gem.files = FileList['Rakefile', 'README*', 'CHANGELOG', 'spec/**/*','tasks/*', 'lib/**/*'].to_a
|
29
|
+
gem.test_files = FileList['spec/**/*.rb']
|
30
|
+
gem.rdoc_options <<
|
31
|
+
"--line-numbers" <<
|
32
|
+
"--inline-source" <<
|
33
|
+
"--title" << SUMMARY <<
|
34
|
+
"-m" << "README.rdoc"
|
35
|
+
|
36
|
+
gem.files.reject! { |fn| fn =~ /PostInstall.txt|pkg\/|rdoc\// }
|
37
|
+
gem.extra_rdoc_files = %w[CHANGELOG LICENSE README.rdoc bin/newrelic_ia]
|
38
|
+
gem.add_dependency 'newrelic_rpm', '>=2.10.6'
|
39
|
+
gem.post_install_message = File.read 'PostInstall.txt'
|
40
|
+
end
|
41
|
+
Jeweler::GemcutterTasks.new
|
42
|
+
rescue LoadError
|
43
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
44
|
+
end
|
45
|
+
|
46
|
+
load "#{File.dirname(__FILE__)}/tasks/rspec.rake"
|
47
|
+
|
48
|
+
task :manifest do
|
49
|
+
puts "Manifest task is no longer used since switching to jeweler."
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
require 'rcov/rcovtask'
|
54
|
+
Rcov::RcovTask.new do |test|
|
55
|
+
test.libs << 'test'
|
56
|
+
test.pattern = 'spec/**/*.rb'
|
57
|
+
test.verbose = true
|
58
|
+
end
|
59
|
+
rescue LoadError
|
60
|
+
task :rcov do
|
61
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
require 'spec/rake/spectask'
|
66
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
67
|
+
spec.libs << 'lib' << 'spec'
|
68
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
69
|
+
end
|
70
|
+
|
71
|
+
task :spec => :check_dependencies
|
72
|
+
|
73
|
+
task :default => :spec
|
74
|
+
|
75
|
+
require 'rake/rdoctask'
|
76
|
+
Rake::RDocTask.new do |rdoc|
|
77
|
+
rdoc.title = SUMMARY
|
78
|
+
rdoc.main = "README.rdoc"
|
79
|
+
rdoc.rdoc_files << 'LICENSE' << 'README*' << 'CHANGELOG' << 'lib/**/*.rb' << 'bin/**/*'
|
80
|
+
rdoc.inline_source = true
|
81
|
+
end
|
82
|
+
|
83
|
+
begin
|
84
|
+
require 'sdoc_helpers'
|
85
|
+
rescue LoadError
|
86
|
+
puts "sdoc support not enabled. Please gem install sdoc-helpers."
|
87
|
+
end
|
data/bin/newrelic_ia
CHANGED
@@ -3,10 +3,18 @@
|
|
3
3
|
# Created on 2009-6-15.
|
4
4
|
# Copyright (c) 2009. All rights reserved.
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
begin
|
7
|
+
require 'newrelic_ia'
|
8
|
+
rescue LoadError
|
9
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
10
|
+
begin
|
11
|
+
require 'newrelic_ia'
|
12
|
+
rescue Exception => e
|
13
|
+
# No gem. Must be in development
|
14
|
+
require "#{File.dirname(__FILE__)}/../lib/newrelic_ia"
|
15
|
+
end
|
16
|
+
end
|
8
17
|
require "new_relic/ia/cli"
|
9
|
-
|
10
18
|
status = NewRelic::IA::CLI.execute(STDOUT, ARGV)
|
11
19
|
exit status if status
|
12
20
|
# if execute returned nil, we are running forever:
|
data/lib/new_relic/ia/cli.rb
CHANGED
@@ -1,104 +1,157 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'logger'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@log = Logger.new(STDOUT)
|
4
|
+
module NewRelic::IA
|
5
|
+
|
6
|
+
class InitError < StandardError; end
|
8
7
|
|
9
|
-
class
|
10
|
-
attr_accessor :log
|
11
|
-
def level= l
|
12
|
-
@log.level = l
|
13
|
-
end
|
8
|
+
class CLI
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
10
|
+
LOGFILE = "newrelic_ia.log"
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def log
|
15
|
+
@log ||= Logger.new LOGFILE
|
16
|
+
end
|
17
|
+
|
18
|
+
def level= l
|
19
|
+
log.level = l
|
20
|
+
end
|
21
|
+
|
22
|
+
# Run the command line args. Return nil if running
|
23
|
+
# or an exit status if not.
|
24
|
+
def execute(stdout, arguments=[])
|
25
|
+
@aspects = []
|
26
|
+
parser = OptionParser.new do |opts|
|
27
|
+
opts.banner = <<-BANNER.gsub(/^ */,'')
|
28
|
+
New Relic Infrastructure Agent (IA) version #{NewRelic::IA::VERSION}
|
24
29
|
Monitor different aspects of your environment with New Relic RPM.
|
25
30
|
|
26
31
|
Usage: #{File.basename($0)} [ options ] aspect, aspect..
|
27
32
|
|
28
|
-
aspect: one or more of 'iostat' or 'disk' (more to come)
|
33
|
+
aspect: one or more of 'memcached', 'iostat' or 'disk' (more to come)
|
29
34
|
BANNER
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
35
|
+
opts.separator ""
|
36
|
+
opts.on("-a", "--all",
|
37
|
+
"use all available aspects") { @aspects = %w[iostat disk memcached] }
|
38
|
+
opts.on("-v", "--verbose",
|
39
|
+
"debug output") { NewRelic::IA::CLI.log.level = Logger::DEBUG }
|
40
|
+
opts.on("-q", "--quiet",
|
41
|
+
"quiet output") { NewRelic::IA::CLI.log.level = Logger::ERROR }
|
42
|
+
opts.on("-e", "--environment=ENV",
|
43
|
+
"use ENV section in newrelic.yml") { |e| @env = e }
|
44
|
+
opts.on("--install",
|
45
|
+
"create a default newrelic.yml") { |e| return self.install(stdout) }
|
46
|
+
|
47
|
+
opts.on("-h", "--help",
|
48
|
+
"Show this help message.") { stdout.puts "#{opts}\n"; return 0 }
|
49
|
+
begin
|
50
|
+
args = opts.parse! arguments
|
51
|
+
unless args.empty?
|
52
|
+
@aspects = args
|
53
|
+
end
|
54
|
+
rescue => e
|
55
|
+
stdout.puts e
|
56
|
+
stdout.puts opts
|
57
|
+
return 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
@aspects.delete_if do |aspect|
|
61
|
+
unless self.instance_methods(false).include? aspect
|
62
|
+
stdout.puts "Unknown aspect: #{aspect}"
|
63
|
+
true
|
48
64
|
end
|
49
|
-
|
50
|
-
|
51
|
-
stdout.puts
|
65
|
+
end
|
66
|
+
if @aspects.empty?
|
67
|
+
stdout.puts "No aspects specified."
|
68
|
+
stdout.puts parser
|
52
69
|
return 1
|
53
70
|
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
71
|
+
require_newrelic_rpm
|
72
|
+
NewRelic::Agent.manual_start :env => @env, :monitor_mode => true, :log => self.log
|
73
|
+
# connected? due in a future version
|
74
|
+
if not (NewRelic::Agent.instance.connected? rescue true)
|
75
|
+
raise InitError, "Unable to connect to RPM server. Agent not started."
|
59
76
|
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
77
|
+
cli = new
|
78
|
+
@aspects.each do | aspect |
|
79
|
+
cli.send aspect
|
80
|
+
end
|
81
|
+
return nil
|
82
|
+
rescue InitError => e
|
83
|
+
stdout.puts e.message
|
64
84
|
return 1
|
65
85
|
end
|
66
86
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
87
|
+
end
|
88
|
+
# Aspect definitions
|
89
|
+
def iostat # :nodoc:
|
90
|
+
self.class.log.info "Starting iostat monitor..."
|
91
|
+
require 'new_relic/ia/iostat_reader'
|
92
|
+
reader = NewRelic::IA::IostatReader.new
|
93
|
+
Thread.new { reader.run }
|
94
|
+
end
|
95
|
+
|
96
|
+
def disk
|
97
|
+
self.class.log.info "Starting disk sampler..."
|
98
|
+
require 'new_relic/ia/disk_sampler'
|
99
|
+
NewRelic::Agent.instance.stats_engine.add_harvest_sampler NewRelic::IA::DiskSampler.new
|
100
|
+
end
|
101
|
+
|
102
|
+
def memcached
|
103
|
+
require 'new_relic/ia/memcached_sampler'
|
104
|
+
s = NewRelic::IA::MemcachedSampler.new
|
105
|
+
s.check
|
106
|
+
NewRelic::Agent.instance.stats_engine.add_harvest_sampler s
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def log
|
112
|
+
self.class.log
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.require_newrelic_rpm
|
116
|
+
begin
|
117
|
+
require 'newrelic_rpm'
|
118
|
+
rescue Exception => e
|
119
|
+
begin
|
120
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
121
|
+
require 'newrelic_rpm'
|
122
|
+
rescue LoadError
|
123
|
+
$stderr.puts "Unable to load required gem newrelic_rpm"
|
124
|
+
$stderr.puts "Try `gem install newrelic_rpm`"
|
125
|
+
Kernel.exit 1
|
126
|
+
end
|
74
127
|
end
|
75
|
-
return nil
|
76
128
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
129
|
+
|
130
|
+
def self.install stdout
|
131
|
+
require_newrelic_rpm
|
132
|
+
if NewRelic::VersionNumber.new(NewRelic::VERSION::STRING) < '2.12'
|
133
|
+
if File.exists? "newrelic.yml"
|
134
|
+
stdout.puts "A newrelic.yml file already exists. Please remove it before installing another."
|
135
|
+
return 1 # error
|
136
|
+
else
|
137
|
+
FileUtils.copy File.join(File.dirname(__FILE__), "newrelic.yml"), "."
|
138
|
+
stdout.puts "A newrelic.yml template was copied to #{File.expand_path('.')}."
|
139
|
+
stdout.puts "Please add a license key to the file before starting."
|
140
|
+
return 0 # normal
|
141
|
+
end
|
142
|
+
else
|
143
|
+
begin
|
144
|
+
require 'new_relic/command'
|
145
|
+
cmd = NewRelic::Command::Install.new \
|
146
|
+
:src_file => File.join(File.dirname(__FILE__), "newrelic.yml"),
|
147
|
+
:generated_for_user => "Generated on #{Time.now.strftime('%b %d, %Y')}, from version #{NewRelic::IA::VERSION}"
|
148
|
+
cmd.run
|
149
|
+
0 # normal
|
150
|
+
rescue NewRelic::Command::CommandFailure => e
|
151
|
+
stdout.puts e.message
|
152
|
+
1 # error
|
153
|
+
end
|
154
|
+
end
|
102
155
|
end
|
103
156
|
end
|
104
|
-
end
|
157
|
+
end
|