right_agent 0.6.6 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/lib/right_agent/agent.rb +26 -25
  2. data/lib/right_agent/agent_config.rb +28 -2
  3. data/lib/right_agent/command/command_constants.rb +2 -2
  4. data/lib/right_agent/core_payload_types/executable_bundle.rb +3 -21
  5. data/lib/right_agent/core_payload_types/login_user.rb +19 -4
  6. data/lib/right_agent/core_payload_types/recipe_instantiation.rb +7 -1
  7. data/lib/right_agent/core_payload_types/right_script_instantiation.rb +7 -1
  8. data/lib/right_agent/dispatcher.rb +6 -19
  9. data/lib/right_agent/idempotent_request.rb +72 -17
  10. data/lib/right_agent/monkey_patches/ruby_patch.rb +0 -1
  11. data/lib/right_agent/monkey_patches.rb +0 -1
  12. data/lib/right_agent/operation_result.rb +27 -4
  13. data/lib/right_agent/packets.rb +47 -23
  14. data/lib/right_agent/platform/darwin.rb +33 -2
  15. data/lib/right_agent/platform/linux.rb +98 -2
  16. data/lib/right_agent/platform/windows.rb +41 -6
  17. data/lib/right_agent/platform.rb +11 -2
  18. data/lib/right_agent/scripts/agent_controller.rb +2 -1
  19. data/lib/right_agent/scripts/agent_deployer.rb +2 -2
  20. data/lib/right_agent/scripts/stats_manager.rb +7 -3
  21. data/lib/right_agent/sender.rb +45 -28
  22. data/lib/right_agent.rb +2 -5
  23. data/right_agent.gemspec +5 -3
  24. data/spec/agent_config_spec.rb +1 -1
  25. data/spec/agent_spec.rb +26 -20
  26. data/spec/core_payload_types/login_user_spec.rb +7 -3
  27. data/spec/idempotent_request_spec.rb +218 -48
  28. data/spec/operation_result_spec.rb +19 -0
  29. data/spec/packets_spec.rb +42 -1
  30. data/spec/platform/darwin.rb +11 -0
  31. data/spec/platform/linux.rb +23 -0
  32. data/spec/platform/linux_volume_manager_spec.rb +43 -43
  33. data/spec/platform/platform_spec.rb +35 -32
  34. data/spec/platform/windows.rb +11 -0
  35. data/spec/sender_spec.rb +21 -25
  36. metadata +47 -40
  37. data/lib/right_agent/broker_client.rb +0 -686
  38. data/lib/right_agent/ha_broker_client.rb +0 -1327
  39. data/lib/right_agent/monkey_patches/amqp_patch.rb +0 -274
  40. data/lib/right_agent/monkey_patches/ruby_patch/string_patch.rb +0 -107
  41. data/lib/right_agent/stats_helper.rb +0 -745
  42. data/spec/broker_client_spec.rb +0 -962
  43. data/spec/ha_broker_client_spec.rb +0 -1695
  44. data/spec/monkey_patches/amqp_patch_spec.rb +0 -100
  45. data/spec/monkey_patches/string_patch_spec.rb +0 -99
  46. data/spec/stats_helper_spec.rb +0 -686
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2009-2011 RightScale Inc
1
+ # Copyright (c) 2009-2012 RightScale Inc
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -49,6 +49,13 @@ module RightScale
49
49
  # Shard scope value meaning restrict sending request only to agents with no shard id
50
50
  GLOBAL = 0
51
51
 
52
+ # Instance variables that are not serialized because they are only used locally
53
+ NOT_SERIALIZED = ["received_at"]
54
+
55
+ # (Float) Time in seconds in Unix-epoch when message was received
56
+ attr_accessor :received_at
57
+
58
+ # (Integer) Size of packet in bytes
52
59
  attr_accessor :size
53
60
 
54
61
  def initialize
@@ -87,7 +94,11 @@ module RightScale
87
94
  def to_msgpack(*a)
88
95
  msg = {
89
96
  'msgpack_class' => self.class.name,
90
- 'data' => instance_variables.inject({}) { |m, ivar| m[ivar.to_s.sub(/@/,'')] = instance_variable_get(ivar); m },
97
+ 'data' => instance_variables.inject({}) do |m, ivar|
98
+ name = ivar.to_s.sub(/@/, '')
99
+ m[name] = instance_variable_get(ivar) unless NOT_SERIALIZED.include?(name)
100
+ m
101
+ end,
91
102
  'size' => nil
92
103
  }.to_msgpack(*a)
93
104
  @size = msg.size
@@ -111,7 +122,11 @@ module RightScale
111
122
 
112
123
  js = {
113
124
  'json_class' => class_name,
114
- 'data' => instance_variables.inject({}) { |m, ivar| m[ivar.to_s.sub(/@/,'')] = instance_variable_get(ivar); m }
125
+ 'data' => instance_variables.inject({}) do |m, ivar|
126
+ name = ivar.to_s.sub(/@/, '')
127
+ m[name] = instance_variable_get(ivar) unless NOT_SERIALIZED.include?(name)
128
+ m
129
+ end
115
130
  }.to_json(*a)
116
131
  @size = js.size
117
132
  js = js.chop + ",\"size\":#{@size}}"
@@ -137,7 +152,11 @@ module RightScale
137
152
  v = __send__(version) if version
138
153
  v = (v && v != DEFAULT_VERSION) ? " v#{v}" : ""
139
154
  log_msg = "[#{name}#{v}]"
140
- duration = ", #{enough_precision(@duration)} sec" if @duration && (filter.nil? || filter.include?(:duration))
155
+ duration = if @duration && (filter.nil? || filter.include?(:duration))
156
+ ", #{enough_precision(@duration)} sec"
157
+ elsif @received_at && (filter.nil? || filter.include?(:local_duration))
158
+ ", #{enough_precision(Time.now.to_f - @received_at)} sec"
159
+ end
141
160
  log_msg += " (#{@size.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")} bytes#{duration})" if @size && !@size.to_s.empty?
142
161
  log_msg
143
162
  end
@@ -175,6 +194,23 @@ module RightScale
175
194
  if id == modified_id then modified_id else "*#{modified_id}" end
176
195
  end
177
196
 
197
+ # Generate log friendly serialized identity for one or more ids
198
+ # Limit to 1000 bytes
199
+ #
200
+ # === Parameters
201
+ # ids(Array|String):: Serialized identity or array of serialized identities
202
+ #
203
+ # === Return
204
+ # (String):: Log friendly serialized identity
205
+ def ids_to_s(ids)
206
+ if ids.is_a?(Array)
207
+ s = ids.each { |i| id_to_s(i) }.join(', ')
208
+ s.size > 1000 ? "[#{s[0, 1000]}...]" : "[#{s}]"
209
+ else
210
+ id_to_s(ids)
211
+ end
212
+ end
213
+
178
214
  # Convert serialized AgentIdentity to compatible format
179
215
  #
180
216
  # === Parameters
@@ -209,17 +245,7 @@ module RightScale
209
245
  def trace
210
246
  audit_id = self.respond_to?(:payload) && payload.is_a?(Hash) && (payload['audit_id'] || payload[:audit_id])
211
247
  tok = self.respond_to?(:token) && token
212
- tr = ''
213
- if audit_id || tok
214
- tr = '<'
215
- if audit_id
216
- tr += audit_id.to_s
217
- tr += ':' if tok
218
- end
219
- tr += tok if tok
220
- tr += '>'
221
- end
222
- tr
248
+ tr = "<#{audit_id || nil}> <#{tok}>"
223
249
  end
224
250
 
225
251
  # Retrieve protocol version of original creator of packet
@@ -266,7 +292,7 @@ module RightScale
266
292
  # :reply_to(String):: Identity of the node that actor replies to, usually a mapper itself
267
293
  # :selector(Symbol):: Selector used to route the request: :any or :all, defaults to :any,
268
294
  # :all deprecated for version 13 and above
269
- # :target(String):: Target recipient
295
+ # :target(String|Array):: Target recipient(s)
270
296
  # :persistent(Boolean):: Indicates if this request should be saved to persistent storage
271
297
  # by the AMQP broker
272
298
  # :expires_at(Integer|nil):: Time in seconds in Unix-epoch when this request expires and
@@ -339,14 +365,14 @@ module RightScale
339
365
  log_msg = "#{super(filter, version)} #{trace} #{@type}"
340
366
  log_msg += " #{payload}" if payload
341
367
  log_msg += " from #{id_to_s(@from)}" if filter.nil? || filter.include?(:from)
342
- log_msg += ", target #{id_to_s(@target)}" if @target && (filter.nil? || filter.include?(:target))
368
+ log_msg += ", target #{ids_to_s(@target)}" if @target && (filter.nil? || filter.include?(:target))
343
369
  log_msg += ", scope #{@scope.inspect}" if @scope && (filter.nil? || filter.include?(:scope))
344
370
  log_msg += ", fanout" if (filter.nil? || filter.include?(:fanout)) && fanout?
345
371
  log_msg += ", reply_to #{id_to_s(@reply_to)}" if @reply_to && (filter.nil? || filter.include?(:reply_to))
346
372
  log_msg += ", tags #{@tags.inspect}" if @tags && !@tags.empty? && (filter.nil? || filter.include?(:tags))
347
373
  log_msg += ", persistent" if @persistent && (filter.nil? || filter.include?(:persistent))
348
374
  log_msg += ", tries #{tries_to_s}" if @tries && !@tries.empty? && (filter.nil? || filter.include?(:tries))
349
- log_msg += ", payload #{@payload.inspect}" if filter.nil? || filter.include?(:payload)
375
+ log_msg += ", payload #{@payload.inspect}" if filter && filter.include?(:payload)
350
376
  log_msg
351
377
  end
352
378
 
@@ -395,7 +421,7 @@ module RightScale
395
421
  # :scope(Hash):: Define behavior that should be used to resolve tag based routing
396
422
  # :token(String):: Generated request id that a mapper uses to identify replies
397
423
  # :selector(Symbol):: Selector used to route the request: :any or :all, defaults to :any
398
- # :target(String):: Target recipient
424
+ # :target(String|Array):: Target recipient(s)
399
425
  # :persistent(Boolean):: Indicates if this request should be saved to persistent storage
400
426
  # by the AMQP broker
401
427
  # :confirm(Boolean):: Whether require confirmation response from mapper containing targets
@@ -403,8 +429,6 @@ module RightScale
403
429
  # :expires_at(Integer|nil):: Time in seconds in Unix-epoch when this request expires and
404
430
  # is to be ignored by the receiver; value 0 means never expire; defaults to 0
405
431
  # :tags(Array(Symbol)):: List of tags to be used for selecting target for this request
406
- # :tries(Array):: List of tokens for previous attempts to send this request (only here
407
- # for consistency with Request)
408
432
  # version(Array):: Protocol version of the original creator of the packet followed by the
409
433
  # protocol version of the packet contents to be used when sending
410
434
  # size(Integer):: Size of request in bytes used only for marshalling
@@ -473,12 +497,12 @@ module RightScale
473
497
  log_msg = "#{super(filter, version)} #{trace} #{@type}"
474
498
  log_msg += " #{payload}" if payload
475
499
  log_msg += " from #{id_to_s(@from)}" if filter.nil? || filter.include?(:from)
476
- log_msg += ", target #{id_to_s(@target)}" if @target && (filter.nil? || filter.include?(:target))
500
+ log_msg += ", target #{ids_to_s(@target)}" if @target && (filter.nil? || filter.include?(:target))
477
501
  log_msg += ", scope #{@scope.inspect}" if @scope && (filter.nil? || filter.include?(:scope))
478
502
  log_msg += ", fanout" if (filter.nil? || filter.include?(:fanout)) && fanout?
479
503
  log_msg += ", tags #{@tags.inspect}" if @tags && !@tags.empty? && (filter.nil? || filter.include?(:tags))
480
504
  log_msg += ", persistent" if @persistent && (filter.nil? || filter.include?(:persistent))
481
- log_msg += ", payload #{@payload.inspect}" if filter.nil? || filter.include?(:payload)
505
+ log_msg += ", payload #{@payload.inspect}" if filter && filter.include?(:payload)
482
506
  log_msg
483
507
  end
484
508
 
@@ -63,15 +63,40 @@ module RightScale
63
63
  return nil
64
64
  end
65
65
 
66
- # Path to directory containing generated agent configuration files
66
+ # Directory containing generated agent configuration files
67
+ # @deprecated
67
68
  def cfg_dir
68
- '/etc/right_agent'
69
+ warn "cfg_dir is deprecated; please use right_agent_cfg_dir"
70
+ right_agent_cfg_dir
69
71
  end
70
72
 
73
+ # RightScale state directory for the current platform
74
+ # @deprecated
71
75
  def right_scale_state_dir
76
+ warn "right_scale_state_dir is deprecated; please use either right_scale_static_state_dir or right_agent_dynamic_state_dir"
77
+ right_scale_static_state_dir
78
+ end
79
+
80
+ # Directory containing generated agent configuration files
81
+ def right_agent_cfg_dir
82
+ '/etc/right_agent'
83
+ end
84
+
85
+ # Static (time-invariant) state that is common to all RightScale apps/agents
86
+ def right_scale_static_state_dir
72
87
  '/etc/rightscale.d'
73
88
  end
74
89
 
90
+ # Static (time-invariant) state that is specific to RightLink
91
+ def right_link_static_state_dir
92
+ '/etc/rightscale.d/right_link'
93
+ end
94
+
95
+ # Dynamic, persistent runtime state that is specific to RightLink
96
+ def right_link_dynamic_state_dir
97
+ '/var/lib/rightscale/right_link'
98
+ end
99
+
75
100
  def spool_dir
76
101
  '/var/spool'
77
102
  end
@@ -235,6 +260,12 @@ module RightScale
235
260
  return `ps -o rss= -p #{pid}`.to_i
236
261
  end
237
262
  end
263
+
264
+ class Installer
265
+ def install(packages)
266
+ raise "not yet implemented"
267
+ end
268
+ end
238
269
 
239
270
  end # Platform
240
271
 
@@ -114,15 +114,40 @@ module RightScale
114
114
  return nil
115
115
  end
116
116
 
117
- # Path to directory containing generated agent configuration files
117
+ # Directory containing generated agent configuration files
118
+ # @deprecated
118
119
  def cfg_dir
119
- '/etc/right_agent'
120
+ warn "cfg_dir is deprecated; please use right_agent_cfg_dir"
121
+ right_agent_cfg_dir
120
122
  end
121
123
 
124
+ # RightScale state directory for the current platform
125
+ # @deprecated
122
126
  def right_scale_state_dir
127
+ warn "right_scale_state_dir is deprecated; please use either right_scale_static_state_dir or right_agent_dynamic_state_dir"
128
+ right_scale_static_state_dir
129
+ end
130
+
131
+ # Directory containing generated agent configuration files
132
+ def right_agent_cfg_dir
133
+ '/var/lib/rightscale/right_agent'
134
+ end
135
+
136
+ # Static (time-invariant) state that is common to all RightScale apps/agents
137
+ def right_scale_static_state_dir
123
138
  '/etc/rightscale.d'
124
139
  end
125
140
 
141
+ # Static (time-invariant) state that is specific to RightLink
142
+ def right_link_static_state_dir
143
+ '/etc/rightscale.d/right_link'
144
+ end
145
+
146
+ # Dynamic, persistent runtime state that is specific to RightLink
147
+ def right_link_dynamic_state_dir
148
+ '/var/lib/rightscale/right_link'
149
+ end
150
+
126
151
  def spool_dir
127
152
  '/var/spool'
128
153
  end
@@ -417,6 +442,77 @@ module RightScale
417
442
  return `ps -o rss= -p #{pid}`.to_i
418
443
  end
419
444
  end
445
+
446
+ class Installer
447
+ # The output generated by the Installer class
448
+ attr_accessor :output
449
+
450
+ @output = ""
451
+
452
+ class PackageNotFound < Exception; end
453
+ class PackageManagerNotFound < Exception; end
454
+
455
+ # Does this machine have aptitude
456
+ #
457
+ # === Return
458
+ # true:: If aptitude is available in the expected directory
459
+ # false:: Otherwise
460
+ def aptitude?
461
+ File.executable? '/usr/bin/apt-get'
462
+ end
463
+
464
+ # Does this machine have yum
465
+ #
466
+ # === Return
467
+ # true:: If yum is available in the expected directory
468
+ # false:: Otherwise
469
+ def yum?
470
+ File.executable? '/usr/bin/yum'
471
+ end
472
+
473
+ # Does this machine have zypper
474
+ #
475
+ # === Return
476
+ # true:: If zypper is available in the expected directory
477
+ # false:: Otherwise
478
+ def zypper?
479
+ File.executable? '/usr/bin/zypper'
480
+ end
481
+
482
+ # Install packages based on installed package manager
483
+ #
484
+ # === Parameters
485
+ # command_name(Array):: Array of packages names to be installed
486
+ #
487
+ # === Return
488
+ # true:: If installations of all packages was successfull
489
+ # false:: Otherwise
490
+ def install(packages)
491
+ return true if packages.empty?
492
+
493
+ packages = packages.uniq.join(' ')
494
+ failed_packages = []
495
+
496
+ if yum?
497
+ command = "yum install -y #{packages} 2>&1"
498
+ regex = /No package (.*) available\./
499
+ elsif aptitude?
500
+ ENV['DEBIAN_FRONTEND'] = "noninteractive"
501
+ command = "apt-get install -y #{packages} 2>&1"
502
+ regex = /E: Couldn't find package (.*)/
503
+ elsif zypper?
504
+ command = "zypper --no-gpg-checks -n #{packages} 2>&1"
505
+ regex = /Package '(.*)' not found\./
506
+ else
507
+ raise PackageManagerNotFound, "No package manager binary (apt, yum, zypper) found in /usr/bin"
508
+ end
509
+
510
+ @output = `#{command}`
511
+ @output.scan(regex) { |package| failed_packages << package.first }
512
+ raise PackageNotFound, "The following packages were not available: #{failed_packages.join(', ')}" unless failed_packages.empty?
513
+ return true
514
+ end
515
+ end
420
516
 
421
517
  end # Platform
422
518
 
@@ -60,7 +60,6 @@ module RightScale
60
60
 
61
61
  attr_reader :flavor, :release
62
62
 
63
- # TODO Initialize flavor and release (need to run on windows to finalize)
64
63
  def init
65
64
  getversionex = Win32API.new("kernel32", "GetVersionEx", 'P', 'L')
66
65
  osversioninfo = [
@@ -74,6 +73,8 @@ module RightScale
74
73
 
75
74
  raise 'Failed to detect Windows version' if 0 == getversionex.call(osversioninfo) # zero is failure
76
75
  version = osversioninfo.unpack('LLLLLZ128') # 'Z' means ASCIIZ string
76
+ @flavor = 'windows' # there can be only one
77
+ @release = "#{version[1]}.#{version[2]}.#{version[3]}"
77
78
  end
78
79
 
79
80
  class Filesystem
@@ -136,15 +137,39 @@ module RightScale
136
137
  end
137
138
 
138
139
  # Directory containing generated agent configuration files
140
+ # @deprecated
139
141
  def cfg_dir
140
- return pretty_path(File.join(Dir::COMMON_APPDATA, 'RightScale', 'right_agent'))
142
+ warn "cfg_dir is deprecated; please use right_agent_cfg_dir"
143
+ right_agent_cfg_dir
141
144
  end
142
145
 
143
146
  # RightScale state directory for the current platform
147
+ # @deprecated
144
148
  def right_scale_state_dir
149
+ warn "right_scale_state_dir is deprecated; please use either right_scale_static_state_dir or right_agent_dynamic_state_dir"
150
+ right_scale_static_state_dir
151
+ end
152
+
153
+ # Directory containing generated agent configuration files
154
+ def right_agent_cfg_dir
155
+ return pretty_path(File.join(Dir::COMMON_APPDATA, 'RightScale', 'right_agent'))
156
+ end
157
+
158
+ # Static (time-invariant) state that is common to all RightScale apps/agents
159
+ def right_scale_static_state_dir
145
160
  return pretty_path(File.join(Dir::COMMON_APPDATA, 'RightScale', 'rightscale.d'))
146
161
  end
147
162
 
163
+ # Static (time-invariant) state that is specific to RightLink
164
+ def right_link_static_state_dir
165
+ return pretty_path(File.join(Dir::COMMON_APPDATA, 'RightScale', 'rightscale.d', 'right_link'))
166
+ end
167
+
168
+ # Dynamic, persistent runtime state that is specific to RightLink
169
+ def right_link_dynamic_state_dir
170
+ return pretty_path(File.join(Dir::COMMON_APPDATA, 'RightScale', 'right_link'))
171
+ end
172
+
148
173
  # Spool directory for the current platform
149
174
  def spool_dir
150
175
  return pretty_path(File.join(Dir::COMMON_APPDATA, 'RightScale', 'spool'))
@@ -950,7 +975,9 @@ EOF
950
975
  escaped = []
951
976
  [shell_script_file_path, arguments].flatten.each do |arg|
952
977
  value = arg.to_s
953
- escaped << (value.index(' ') ? "'#{value.gsub("'", "''")}'" : value)
978
+ # note that literal ampersand must be quoted on the powershell command
979
+ # line because it otherwise means 'execute what follows'.
980
+ escaped << ((value.index(' ') || value.index('&')) ? "'#{value.gsub("'", "''")}'" : value)
954
981
  end
955
982
 
956
983
  # resolve lines before & after script.
@@ -1082,7 +1109,11 @@ EOF
1082
1109
  # the UTC timestamp at which the system was booted
1083
1110
  def booted_at
1084
1111
  begin
1085
- wmic_output = `echo | wmic OS Get LastBootUpTime`
1112
+ Dir.mktmpdir do |temp_dir_path|
1113
+ Dir.chdir(temp_dir_path) do
1114
+ wmic_output = `echo | wmic OS Get LastBootUpTime`
1115
+ end
1116
+ end
1086
1117
 
1087
1118
  match = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.\d{6}([+-]\d{3})/.match(wmic_output)
1088
1119
 
@@ -1213,8 +1244,12 @@ EOF
1213
1244
  return process_memory_counters[12..16].unpack("L")[0] / 1024 # bytes to KB
1214
1245
  end
1215
1246
  end
1216
-
1217
- protected
1247
+
1248
+ class Installer
1249
+ def install(packages)
1250
+ raise ::RightScale::Win32Error.new("Not implemented yet")
1251
+ end
1252
+ end
1218
1253
 
1219
1254
  # internal class for querying OS version, etc.
1220
1255
  class OSInformation
@@ -54,7 +54,7 @@ module RightScale
54
54
  # - .flavor
55
55
  # - .release
56
56
  # - .linux?
57
- # - .mac?
57
+ # - .darwin?
58
58
  # - .windows?
59
59
  # - .ec2?
60
60
  # - .rackspace?
@@ -241,6 +241,14 @@ module RightScale
241
241
  def process
242
242
  platform_service(:process)
243
243
  end
244
+
245
+ # Installer information object
246
+ #
247
+ # === Return
248
+ # (Object):: Platform-specific installer information object
249
+ def installer
250
+ platform_service(:installer)
251
+ end
244
252
 
245
253
  private
246
254
 
@@ -251,6 +259,7 @@ module RightScale
251
259
  @shell = nil
252
260
  @ssh = nil
253
261
  @controller = nil
262
+ @installer = nil
254
263
 
255
264
  @ec2 = nil
256
265
  @rackspace = nil
@@ -293,7 +302,7 @@ module RightScale
293
302
  # Retrieve platform specific service implementation
294
303
  #
295
304
  # === Parameters
296
- # name(Symbol):: Service name, one of :filesystem, :shell, :ssh, :controller
305
+ # name(Symbol):: Service name, one of :filesystem, :shell, :ssh, :controller, :installer
297
306
  #
298
307
  # === Return
299
308
  # res(Object):: Service instance
@@ -334,7 +334,8 @@ module RightScale
334
334
  EM.error_handler do |e|
335
335
  Log.error("EM block execution failed with exception", e, :trace)
336
336
  Log.error("\n\n===== Exiting due to EM block exception =====\n\n")
337
- EM.stop
337
+ # Cannot rely on EM.stop at this point, so exit to give chance for monit restart
338
+ exit(1)
338
339
  end
339
340
 
340
341
  EM.run do
@@ -289,8 +289,8 @@ module RightScale
289
289
  cfg[:prefetch] = options[:prefetch] || 1
290
290
  cfg[:heartbeat] = options[:heartbeat] if options[:heartbeat]
291
291
  cfg[:time_to_live] = options[:time_to_live] || 60
292
- cfg[:retry_timeout] = options[:retry_timeout] || 2 * 60
293
- cfg[:retry_interval] = options[:retry_interval] || 15
292
+ cfg[:retry_timeout] = options[:retry_timeout] || 60
293
+ cfg[:retry_interval] = options[:retry_interval] || 5
294
294
  cfg[:ping_interval] = options[:ping_interval] ||= 4 * 60 * 60
295
295
  cfg[:check_interval] = options[:check_interval] if options[:check_interval]
296
296
  cfg[:reconnect_interval] = options[:reconnect_interval] if options[:reconnect_interval]
@@ -38,8 +38,6 @@ module RightScale
38
38
 
39
39
  class StatsManager
40
40
 
41
- include StatsHelper
42
-
43
41
  # Default time to wait for a response from an agent
44
42
  DEFAULT_TIMEOUT = 5
45
43
 
@@ -185,6 +183,7 @@ module RightScale
185
183
  Log.program_name = "stats_manager"
186
184
  Log.log_to_file_only(true)
187
185
  Log.init("stats_manager", Platform.filesystem.temp_dir, :print => true)
186
+ RightSupport::Log::Mixin.default_logger = Log
188
187
  true
189
188
  end
190
189
 
@@ -207,6 +206,10 @@ module RightScale
207
206
  # result(String):: Result packet in JSON format containing stats or error
208
207
  # options(Hash):: Command line options:
209
208
  # :json(Boolean):: Whether to display in JSON format
209
+ # :name_width(Integer):: Maximum characters in displayed stat name
210
+ # :sub_name_width(Integer):: Maximum characters in displayed sub-stat name
211
+ # :sub_stat_value_width(Integer):: Maximum characters in displayed sub-stat value line
212
+ # :exception_message_width(Integer):: Maximum characters displayed for exception message
210
213
  #
211
214
  # === Return
212
215
  # true:: Always return true
@@ -216,7 +219,8 @@ module RightScale
216
219
  $stdout.puts result.content.to_json
217
220
  else
218
221
  if result.respond_to?(:success?) && result.success?
219
- $stdout.puts "\n#{stats_str(result.content)}\n"
222
+ stats = RightSupport::Stats.stats_str(result.content, options)
223
+ $stdout.puts "\n#{stats}\n"
220
224
  else
221
225
  $stderr.puts "\nCould not retrieve #{agent_name} agent stats: #{result.inspect}"
222
226
  end