ganymed 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/ganymed CHANGED
@@ -5,15 +5,27 @@ $:.unshift(File.join(File.expand_path("../..", __FILE__), 'lib'))
5
5
 
6
6
  $0 = "ganymed"
7
7
 
8
- require 'madvertise/ext/logging'
9
8
  require 'madvertise/ext/environment'
10
9
  Env.key = 'GANYMED_ENV'
11
10
 
11
+ require 'madvertise-logging'
12
+ $log = ImprovedLogger.new(:stdout, $0)
13
+
12
14
  require 'ganymed/master'
13
15
  cli = Ganymed::Master::CLI.parse_options
14
16
  server = Ganymed::Master.new(cli.config)
15
17
 
16
- log.level = :debug if cli.config[:debug]
18
+ $log.level = :debug if cli.config[:debug]
19
+
20
+ $config ||= Configuration.new do |config|
21
+ config.mixin(File.join(Ganymed::LIB_DIR, 'ganymed/config.yml'))
22
+ config.mixin(cli.config[:config_file]) if cli.config[:config_file]
23
+ end
24
+
25
+ if Env.prod?
26
+ Madvertise::Logging::ImprovedLogger::Formatter.
27
+ format = "<%{syslog_severity}>%{msg}\n"
28
+ end
17
29
 
18
30
  if cli.config[:daemonize] or cli.config[:kill]
19
31
  daemon = Servolux::Daemon.new(:server => server)
data/ganymed.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
19
19
  # master
20
20
  s.add_dependency "activesupport", ">= 3.2"
21
21
  s.add_dependency "eventmachine", ">= 0.12.10"
22
- s.add_dependency "madvertise-ext", ">= 0.1.2"
23
- s.add_dependency "madvertise-logging", ">= 0.3.2"
22
+ s.add_dependency "madvertise-ext", ">= 0.4.0"
23
+ s.add_dependency "madvertise-logging", ">= 1.0.0"
24
24
  s.add_dependency "mixlib-cli"
25
25
  s.add_dependency "servolux"
26
26
 
@@ -55,9 +55,9 @@ module Ganymed
55
55
  config = @config.collectors[name.to_sym] || Section.new
56
56
  config.name = name
57
57
 
58
- log.debug("loading collector #{name} from #{file}")
58
+ $log.debug("loading collector #{name} from #{file}")
59
59
  Plugin.new(config).from_file(file).tap do |collector|
60
- log.info("collecting #{name} metrics every #{collector.interval} seconds")
60
+ $log.info("collecting #{name} metrics every #{collector.interval} seconds")
61
61
  collector.run
62
62
  end
63
63
  end
@@ -70,7 +70,7 @@ module Ganymed
70
70
 
71
71
  [].tap do |files|
72
72
  load_paths.each do |load_path|
73
- log.debug("loading collectors from #{load_path}")
73
+ $log.debug("loading collectors from #{load_path}")
74
74
  Dir[File.join(load_path, '*.rb')].each do |file|
75
75
  files << file
76
76
  end
@@ -130,8 +130,8 @@ module Ganymed
130
130
  @splay = 0
131
131
  rescue Exception => exc
132
132
  @splay += 1
133
- log.exception(exc)
134
- log.info("slowing down collector #{config.name}", interval: @interval, splay: @splay)
133
+ $log.exception(exc)
134
+ $log.info("slowing down collector #{config.name}", interval: @interval, splay: @splay)
135
135
  end
136
136
 
137
137
  # Loads a given ruby file, and runs instance_eval against it in the
@@ -9,6 +9,9 @@ generic:
9
9
  gcprofiler: false
10
10
  rubyprof: false
11
11
 
12
+ collector:
13
+ load_paths: []
14
+
12
15
  collectors:
13
16
  network:
14
17
  exclude:
@@ -13,74 +13,69 @@ require 'metriks/reporter/logger'
13
13
  module Ganymed
14
14
  # @private
15
15
  class Master < ::Servolux::Server
16
- include Configuration::Helpers
17
16
 
18
17
  def initialize(cli)
19
- # load config file
20
- @default_config_file = File.join(LIB_DIR, 'ganymed/config.yml')
21
- @config_file = cli[:config_file]
22
-
23
18
  # initialize servolux
24
19
  super('ganymed',
25
20
  :interval => 1,
26
- :logger => log,
21
+ :logger => $log,
27
22
  :pid_file => cli[:pidfile])
28
23
  end
29
24
 
30
25
  def run
31
- log.info("starting Ganymed reactor in #{Env.mode} mode")
26
+ $log.info("starting Ganymed reactor in #{Env.mode} mode")
32
27
 
33
28
  # configure eventmachine
34
- log.debug("EventMachine threadpool_size=#{config.eventmachine.threadpool_size}")
35
- EventMachine.threadpool_size = config.eventmachine.threadpool_size
29
+ $log.debug("EventMachine threadpool_size=#{$config.eventmachine.threadpool_size}")
30
+ EventMachine.threadpool_size = $config.eventmachine.threadpool_size
36
31
 
37
32
  EventMachine.epoll # use epoll
38
33
  EventMachine.run do
39
- Collector.new(config) if config.collectors.any?
34
+ Collector.new($config) if $config.collectors.any?
40
35
  Metriks::Reporter::Logger.new({
41
- :logger => log,
42
- :interval => config.interval,
43
- :on_error => ->(e) { log.exception(e) },
36
+ :logger => $log,
37
+ :interval => $config.interval,
38
+ :on_error => ->(e) { $log.exception(e) },
44
39
  }).start
45
40
  end
46
41
 
47
42
  rescue Exception => exc
48
- log.exception(exc)
43
+ $log.exception(exc)
49
44
  end
50
45
 
51
46
  def before_starting
52
- if config.profiling.perftools
53
- log.info("activating PerfTools CPU profiler")
47
+ if $config.profiling.perftools
48
+ $log.info("activating PerfTools CPU profiler")
54
49
  require 'perftools'
55
50
  PerfTools::CpuProfiler.start('profile')
56
51
  end
57
52
 
58
- if config.profiling.gcprofiler
59
- log.info("activating GC::Profiler")
53
+ if $config.profiling.gcprofiler
54
+ $log.info("activating GC::Profiler")
60
55
  GC::Profiler.enable
61
56
  end
62
57
 
63
- if config.profiling.rubyprof
58
+ if $config.profiling.rubyprof
64
59
  require 'ruby-prof'
65
- log.info("activating RubyProf")
60
+ $log.info("activating RubyProf")
66
61
  RubyProf.start
67
62
  end
68
63
  end
69
64
 
70
65
  def before_stopping
71
66
  if EventMachine.reactor_running?
72
- log.info("shutting down Ganymed reactor")
67
+ $log.info("shutting down Ganymed reactor")
73
68
  EventMachine.stop_event_loop
74
69
  end
75
70
  end
76
71
 
77
72
  def after_stopping
78
- if config.profiling.perftools
73
+ if $config.profiling.perftools
79
74
  PerfTools::CpuProfiler.stop
80
75
  `pprof.rb --svg profile > profile.svg`
81
76
  end
82
77
 
83
- if config.profiling.rubyprof
78
+ if $config.profiling.rubyprof
84
79
  result = RubyProf.stop
85
80
  result.eliminate_methods!([
86
81
  /Queue#pop/,
@@ -92,7 +87,7 @@ module Ganymed
92
87
  printer.print(:path => "prof", :profile => "ganymed")
93
88
  end
94
89
 
95
- log.info("done shutting down. exiting ...")
90
+ $log.info("done shutting down. exiting ...")
96
91
  end
97
92
 
98
93
  class CLI
@@ -1,4 +1,4 @@
1
1
  module Ganymed
2
2
  # @private
3
- VERSION = '0.4.4'
3
+ VERSION = '0.5.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ganymed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-11 00:00:00.000000000 Z
12
+ date: 2013-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: 0.1.2
53
+ version: 0.4.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.2
61
+ version: 0.4.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: madvertise-logging
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
- version: 0.3.2
69
+ version: 1.0.0
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
- version: 0.3.2
77
+ version: 1.0.0
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: mixlib-cli
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -176,7 +176,6 @@ email:
176
176
  - bb@xnull.de
177
177
  executables:
178
178
  - ganymed
179
- - ganymed-console
180
179
  extensions: []
181
180
  extra_rdoc_files: []
182
181
  files:
@@ -189,7 +188,6 @@ files:
189
188
  - README.md
190
189
  - Rakefile
191
190
  - bin/ganymed
192
- - bin/ganymed-console
193
191
  - ganymed.gemspec
194
192
  - lib/ganymed.rb
195
193
  - lib/ganymed/collector.rb
@@ -222,7 +220,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
220
  version: '0'
223
221
  segments:
224
222
  - 0
225
- hash: -2160081704488403590
223
+ hash: 2008446248983856620
226
224
  required_rubygems_version: !ruby/object:Gem::Requirement
227
225
  none: false
228
226
  requirements:
@@ -231,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
229
  version: '0'
232
230
  segments:
233
231
  - 0
234
- hash: -2160081704488403590
232
+ hash: 2008446248983856620
235
233
  requirements: []
236
234
  rubyforge_project:
237
235
  rubygems_version: 1.8.25
data/bin/ganymed-console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- $:.unshift(File.join(File.expand_path("../..", __FILE__), 'lib'))
5
-
6
- $0 = "ganymed-console"
7
-
8
- require 'madvertise/ext/logging'
9
- require 'madvertise/ext/environment'
10
- Env.key = 'GANYMED_ENV'
11
-
12
- log.level = :debug
13
-
14
- require 'ganymed/console'
15
- Ganymed::Console.new