newrelic_plugins_hive 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 89142e834945c404998616dd19ae85a99316ce60
4
+ data.tar.gz: 95f5ee6f06f0c96aeb2b050d6c0d47f63f325efe
5
+ SHA512:
6
+ metadata.gz: d782717b6cc3cf27ddd9f08e2fc7a4a3db3370e5344d111b4f992fc688edcf8c8075dd19a3709cdb1e75d0f55d878ec294517061d87e517429dcec97200bd4cd
7
+ data.tar.gz: 887ea3108f30a0ca24b80ab742d446756388f313decc7da21309c87553dafef97538b79c08ac45ee0eb4584d173469d17408249bb79f9272d19e2be169a70f27
@@ -0,0 +1,11 @@
1
+ *.orig
2
+ *~
3
+ *.gem
4
+ .DS_Store
5
+ .bundle
6
+ Gemfile.lock
7
+ pkg/*
8
+
9
+ config/*
10
+ temp/*
11
+ plugins/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in throttler.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Elad Maimon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ Make sure to add plugins dependencies to your Gemfile
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+
5
+ require 'daemons'
6
+ require 'slop'
7
+
8
+ require 'newrelic_plugins_hive'
9
+
10
+ opts = Slop.parse(ARGV, :help => true) do
11
+ on :v, :version, 'Print the version' do
12
+ puts "NewRelic Plugins Hive, version #{NewRelicPluginsHive::VERSION}"
13
+ end
14
+
15
+ command :new do
16
+ banner <<-EOS
17
+ Usage: hive new APP_PATH
18
+ Creates NewRelic Plugins Hive application with a default directory structure at the path you specify'
19
+ EOS
20
+
21
+ run { |opts, args| NewRelicPluginsHive.generate_new_app ARGV[1] }
22
+ end
23
+
24
+ command :install do
25
+ banner 'Install the plugins that defined in config/newrelic_hive.yml'
26
+
27
+ run { |opts, args| NewRelicPluginsHive.install }
28
+ end
29
+
30
+ command :run do
31
+ on :d, :daemon=, 'Daemonizing options. Use: run, start, stop, restart, status'
32
+
33
+ run do |opts, args|
34
+ if opts[:daemon]
35
+ ARGV.clear
36
+ ARGV.push(opts[:daemon])
37
+ Daemons.run(File.dirname(__FILE__) + '/hive_daemon_wrapper')
38
+ else
39
+ NewRelicPluginsHive.run
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ require 'newrelic_plugins_hive'
5
+
6
+ NewRelicPluginsHive.run
@@ -0,0 +1,33 @@
1
+ require 'newrelic_plugins_hive/version'
2
+ require 'newrelic_plugins_hive/configuration'
3
+ require 'newrelic_plugins_hive/new_app_generator/new_app_generator'
4
+ require 'newrelic_plugins_hive/downloader'
5
+ require 'newrelic_plugins_hive/bypass_setup_and_run'
6
+
7
+ module NewRelicPluginsHive
8
+
9
+ class << self
10
+ def config
11
+ @configuration ||= Configuration.new
12
+ end
13
+
14
+ def generate_new_app(path)
15
+ NewAppGenerator.generate_new_app(path)
16
+ end
17
+
18
+ def install
19
+ downloader = Downloader.new
20
+ config.plugins.each { |name, options| downloader.install_plugin(name, options) }
21
+ end
22
+
23
+ def run
24
+ Dir['plugins/*'].each { |file| require file }
25
+
26
+ require "newrelic_plugin"
27
+
28
+ NewRelic::Plugin::Config.config_file = File.dirname(__FILE__) + "/config/newrelic_plugin.yml"
29
+ NewRelic::Plugin::Run.orig_setup_and_run
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,18 @@
1
+ require 'newrelic_plugin'
2
+
3
+ module NewRelicPluginsHive
4
+
5
+ ::NewRelic::Plugin::Run.class_eval do
6
+ class << self
7
+ unless method_defined?(:bypass_setup_and_run)
8
+ define_method(:bypass_setup_and_run) do
9
+ puts "Bypassing setup_and_run"
10
+ end
11
+
12
+ alias_method :orig_setup_and_run, :setup_and_run
13
+ alias_method :setup_and_run, :bypass_setup_and_run
14
+ end
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,28 @@
1
+ module NewRelicPluginsHive
2
+
3
+ class Configuration
4
+ attr_accessor :plugins
5
+
6
+ def initialize
7
+ config_file = File.expand_path('config/newrelic_hive.yml')
8
+ raise "Can't find configuration file: #{config_file}" unless File.exists? config_file
9
+
10
+ configuration = symbolize_keys(YAML.load_file(config_file))
11
+
12
+ @plugins = configuration[:plugins]
13
+ end
14
+
15
+ private
16
+
17
+ def symbolize_keys(hash)
18
+ hash.inject({}) do |res, (key, val)|
19
+ key = key.to_sym
20
+ val = symbolize_keys(val) if val.is_a? Hash
21
+
22
+ res[key] = val
23
+ res
24
+ end
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,39 @@
1
+ module NewRelicPluginsHive
2
+
3
+ class Downloader
4
+ def initialize
5
+ validate_wget_exists
6
+ FileUtils.mkdir_p 'temp'
7
+ FileUtils.mkdir_p 'plugins'
8
+ end
9
+
10
+ def install_plugin(name, options)
11
+ puts "Installing plugin #{name}..."
12
+
13
+ validate_plugin_source
14
+ download_and_extract(name, options)
15
+ end
16
+
17
+ private
18
+
19
+ def validate_wget_exists
20
+ raise "Wget must be installed on your machine. For more help: http://www.gnu.org/software/wget/" unless `wget -V` =~ /^GNU Wget/
21
+ end
22
+
23
+ def validate_plugin_source
24
+ raise "\tMust specify github source for plugin #{name}" unless options[:github] =~ /^https:\/\/github.com/
25
+ end
26
+
27
+ def download_and_extract(name, options)
28
+ `wget -O temp/#{name}.zip #{options[:github]}/archive/master.zip`
29
+
30
+ files_in_zip = `zipinfo -1 temp/#{name}.zip`.split("\n")
31
+ full_agent_path = files_in_zip.find_all {|s| s =~ /#{options[:agent_path]}$/}
32
+
33
+ raise "\tAgent path must exists and be unique in plugin" unless full_agent_path.size == 1
34
+
35
+ `unzip -p temp/#{name}.zip "#{full_agent_path.first}" > plugins/#{options[:agent_path]}`
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,24 @@
1
+ module NewRelicPluginsHive
2
+
3
+ class NewAppGenerator
4
+ def self.generate_new_app(path)
5
+ Dir.mkdir path
6
+
7
+ copy_template 'config/newrelic_hive.yml', path
8
+ copy_template 'config/newrelic_plugin.yml', path
9
+ copy_template 'Gemfile', path
10
+ copy_template 'README.md', path
11
+ end
12
+
13
+ private
14
+
15
+ def self.copy_template(file, path)
16
+ src = File.expand_path("../templates/#{file}", __FILE__)
17
+ dst = File.join Dir.pwd, path, file
18
+
19
+ FileUtils.mkdir_p(File.dirname dst)
20
+ FileUtils.cp src, dst
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'newrelic_plugins_hive'
4
+ gem 'newrelic_plugin'
@@ -0,0 +1,9 @@
1
+ # TODO: Add here the list of the plugins that you want to run in the hive.
2
+ # You should add the url for github repository and the path to the agent inside the repository
3
+ plugins:
4
+ # For example, if you want to run newrelic_sidekiq_agent (https://github.com/mscifo/newrelic_sidekiq_agent)
5
+ # just add those lines:
6
+
7
+ # sidekiq:
8
+ # github: https://github.com/eksoverzero/newrelic_sidekiq_agent
9
+ # agent_path: newrelic_sidekiq_agent
@@ -0,0 +1,19 @@
1
+ # This configuration file holds examples for all plugins.
2
+ # You only need to add the configuration of each plugin under 'agents', as they are appeared in the 'template_newrelic_plugin.yml' of your plugin
3
+ newrelic:
4
+ # TODO: Update the license_key information with the license key for your New Relic account.
5
+ license_key: 'YOUR_LICENSE_KEY_HERE'
6
+
7
+ # Set to '1' for verbose output, remove for normal output.
8
+ verbose: 1
9
+
10
+ agents:
11
+ # TODO: Add here the agent configuration data of each of your plugins.
12
+ # For example, if you want to run newrelic_sidekiq_agent (https://github.com/mscifo/newrelic_sidekiq_agent)
13
+ # then you should add those lines:
14
+
15
+ # sidekiq_status_agent:
16
+ # -
17
+ # instance_name: "instance_name"
18
+ # uri: "uri"
19
+ # namespace: "namespace"
@@ -0,0 +1,3 @@
1
+ module NewRelicPluginsHive
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'newrelic_plugins_hive/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'newrelic_plugins_hive'
8
+ spec.version = NewRelicPluginsHive::VERSION
9
+ spec.authors = ['Elad Maimon']
10
+ spec.email = ['elad.maimon@klarna.com']
11
+ spec.description = %q{This agent consolidates and manages multiple New Relic plugins. It pulls the agents that defined in .yml file and run them all in one process.}
12
+ spec.summary = %q{One process agent for multiple New Relic plugins}
13
+ spec.date = '2013-12-15'
14
+ spec.homepage = 'https://github.com/elad-maimon/newrelic_plugins_hive'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency 'newrelic_plugin'
23
+ spec.add_runtime_dependency 'daemons'
24
+ spec.add_runtime_dependency 'slop'
25
+ spec.add_runtime_dependency 'fileutils'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.3'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'pry'
30
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: newrelic_plugins_hive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Elad Maimon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: newrelic_plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: daemons
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: slop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fileutils
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: This agent consolidates and manages multiple New Relic plugins. It pulls
112
+ the agents that defined in .yml file and run them all in one process.
113
+ email:
114
+ - elad.maimon@klarna.com
115
+ executables:
116
+ - hive
117
+ - hive_daemon_wrapper
118
+ extensions: []
119
+ extra_rdoc_files: []
120
+ files:
121
+ - .gitignore
122
+ - Gemfile
123
+ - LICENSE
124
+ - README.md
125
+ - Rakefile
126
+ - bin/hive
127
+ - bin/hive_daemon_wrapper
128
+ - lib/newrelic_plugins_hive.rb
129
+ - lib/newrelic_plugins_hive/bypass_setup_and_run.rb
130
+ - lib/newrelic_plugins_hive/configuration.rb
131
+ - lib/newrelic_plugins_hive/downloader.rb
132
+ - lib/newrelic_plugins_hive/new_app_generator/new_app_generator.rb
133
+ - lib/newrelic_plugins_hive/new_app_generator/templates/Gemfile
134
+ - lib/newrelic_plugins_hive/new_app_generator/templates/README.md
135
+ - lib/newrelic_plugins_hive/new_app_generator/templates/config/newrelic_hive.yml
136
+ - lib/newrelic_plugins_hive/new_app_generator/templates/config/newrelic_plugin.yml
137
+ - lib/newrelic_plugins_hive/version.rb
138
+ - newrelic_plugins_hive.gemspec
139
+ homepage: https://github.com/elad-maimon/newrelic_plugins_hive
140
+ licenses:
141
+ - MIT
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.1.10
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: One process agent for multiple New Relic plugins
163
+ test_files: []