choria-mcorpc-support 2.21.1 → 2.23.1

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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mcollective.rb +1 -2
  3. data/lib/mcollective/agent/bolt_tasks.ddl +253 -0
  4. data/lib/mcollective/agent/bolt_tasks.json +365 -0
  5. data/lib/mcollective/agent/bolt_tasks.rb +178 -0
  6. data/lib/mcollective/agent/choria_util.ddl +152 -0
  7. data/lib/mcollective/agent/choria_util.json +244 -0
  8. data/lib/mcollective/agent/rpcutil.ddl +8 -4
  9. data/lib/mcollective/agent/rpcutil.json +333 -0
  10. data/lib/mcollective/agent/scout.ddl +169 -0
  11. data/lib/mcollective/agent/scout.json +224 -0
  12. data/lib/mcollective/agents.rb +7 -6
  13. data/lib/mcollective/aggregate.rb +4 -4
  14. data/lib/mcollective/aggregate/average.rb +2 -2
  15. data/lib/mcollective/aggregate/base.rb +2 -2
  16. data/lib/mcollective/aggregate/result.rb +3 -3
  17. data/lib/mcollective/aggregate/result/collection_result.rb +2 -2
  18. data/lib/mcollective/aggregate/result/numeric_result.rb +2 -2
  19. data/lib/mcollective/aggregate/sum.rb +2 -2
  20. data/lib/mcollective/aggregate/summary.rb +3 -4
  21. data/lib/mcollective/application.rb +57 -21
  22. data/lib/mcollective/application/choria.rb +189 -0
  23. data/lib/mcollective/application/completion.rb +6 -6
  24. data/lib/mcollective/application/facts.rb +11 -11
  25. data/lib/mcollective/application/federation.rb +237 -0
  26. data/lib/mcollective/application/find.rb +4 -4
  27. data/lib/mcollective/application/help.rb +3 -3
  28. data/lib/mcollective/application/inventory.rb +3 -341
  29. data/lib/mcollective/application/ping.rb +5 -51
  30. data/lib/mcollective/application/playbook.rb +207 -0
  31. data/lib/mcollective/application/plugin.rb +106 -106
  32. data/lib/mcollective/application/rpc.rb +3 -108
  33. data/lib/mcollective/application/tasks.rb +425 -0
  34. data/lib/mcollective/applications.rb +11 -10
  35. data/lib/mcollective/audit/choria.rb +33 -0
  36. data/lib/mcollective/cache.rb +2 -4
  37. data/lib/mcollective/client.rb +11 -10
  38. data/lib/mcollective/config.rb +21 -34
  39. data/lib/mcollective/connector/base.rb +2 -1
  40. data/lib/mcollective/connector/nats.ddl +9 -0
  41. data/lib/mcollective/connector/nats.rb +450 -0
  42. data/lib/mcollective/data.rb +8 -3
  43. data/lib/mcollective/data/agent_data.rb +1 -1
  44. data/lib/mcollective/data/base.rb +6 -5
  45. data/lib/mcollective/data/bolt_task_data.ddl +90 -0
  46. data/lib/mcollective/data/bolt_task_data.rb +32 -0
  47. data/lib/mcollective/data/collective_data.rb +1 -1
  48. data/lib/mcollective/data/fact_data.rb +6 -6
  49. data/lib/mcollective/data/fstat_data.rb +2 -4
  50. data/lib/mcollective/data/result.rb +7 -2
  51. data/lib/mcollective/ddl/agentddl.rb +5 -17
  52. data/lib/mcollective/ddl/base.rb +10 -13
  53. data/lib/mcollective/discovery.rb +24 -39
  54. data/lib/mcollective/discovery/choria.ddl +11 -0
  55. data/lib/mcollective/discovery/choria.rb +223 -0
  56. data/lib/mcollective/discovery/flatfile.rb +7 -8
  57. data/lib/mcollective/discovery/mc.rb +2 -2
  58. data/lib/mcollective/discovery/stdin.rb +17 -18
  59. data/lib/mcollective/exceptions.rb +13 -0
  60. data/lib/mcollective/facts/base.rb +9 -9
  61. data/lib/mcollective/facts/yaml_facts.rb +12 -12
  62. data/lib/mcollective/generators.rb +3 -3
  63. data/lib/mcollective/generators/agent_generator.rb +3 -4
  64. data/lib/mcollective/generators/base.rb +14 -15
  65. data/lib/mcollective/generators/data_generator.rb +5 -6
  66. data/lib/mcollective/log.rb +2 -2
  67. data/lib/mcollective/logger/base.rb +3 -2
  68. data/lib/mcollective/logger/console_logger.rb +10 -10
  69. data/lib/mcollective/logger/file_logger.rb +7 -7
  70. data/lib/mcollective/logger/syslog_logger.rb +11 -15
  71. data/lib/mcollective/message.rb +8 -39
  72. data/lib/mcollective/monkey_patches.rb +2 -4
  73. data/lib/mcollective/optionparser.rb +2 -1
  74. data/lib/mcollective/pluginmanager.rb +3 -5
  75. data/lib/mcollective/pluginpackager.rb +1 -3
  76. data/lib/mcollective/pluginpackager/agent_definition.rb +3 -8
  77. data/lib/mcollective/pluginpackager/forge_packager.rb +7 -9
  78. data/lib/mcollective/pluginpackager/standard_definition.rb +1 -2
  79. data/lib/mcollective/registration/base.rb +18 -16
  80. data/lib/mcollective/rpc.rb +2 -4
  81. data/lib/mcollective/rpc/actionrunner.rb +16 -18
  82. data/lib/mcollective/rpc/agent.rb +26 -43
  83. data/lib/mcollective/rpc/audit.rb +1 -0
  84. data/lib/mcollective/rpc/client.rb +67 -85
  85. data/lib/mcollective/rpc/helpers.rb +55 -62
  86. data/lib/mcollective/rpc/progress.rb +2 -2
  87. data/lib/mcollective/rpc/reply.rb +17 -19
  88. data/lib/mcollective/rpc/request.rb +7 -5
  89. data/lib/mcollective/rpc/result.rb +6 -8
  90. data/lib/mcollective/rpc/stats.rb +49 -58
  91. data/lib/mcollective/security/base.rb +13 -56
  92. data/lib/mcollective/security/choria.rb +765 -0
  93. data/lib/mcollective/shell.rb +9 -4
  94. data/lib/mcollective/signer/base.rb +28 -0
  95. data/lib/mcollective/signer/choria.rb +185 -0
  96. data/lib/mcollective/ssl.rb +8 -6
  97. data/lib/mcollective/util.rb +58 -55
  98. data/lib/mcollective/util/bolt_support.rb +176 -0
  99. data/lib/mcollective/util/bolt_support/plan_runner.rb +167 -0
  100. data/lib/mcollective/util/bolt_support/task_result.rb +94 -0
  101. data/lib/mcollective/util/bolt_support/task_results.rb +128 -0
  102. data/lib/mcollective/util/choria.rb +946 -0
  103. data/lib/mcollective/util/indifferent_hash.rb +12 -0
  104. data/lib/mcollective/util/natswrapper.rb +242 -0
  105. data/lib/mcollective/util/playbook.rb +435 -0
  106. data/lib/mcollective/util/playbook/data_stores.rb +201 -0
  107. data/lib/mcollective/util/playbook/data_stores/base.rb +99 -0
  108. data/lib/mcollective/util/playbook/data_stores/consul_data_store.rb +88 -0
  109. data/lib/mcollective/util/playbook/data_stores/environment_data_store.rb +33 -0
  110. data/lib/mcollective/util/playbook/data_stores/etcd_data_store.rb +42 -0
  111. data/lib/mcollective/util/playbook/data_stores/file_data_store.rb +106 -0
  112. data/lib/mcollective/util/playbook/data_stores/shell_data_store.rb +103 -0
  113. data/lib/mcollective/util/playbook/inputs.rb +265 -0
  114. data/lib/mcollective/util/playbook/nodes.rb +207 -0
  115. data/lib/mcollective/util/playbook/nodes/mcollective_nodes.rb +86 -0
  116. data/lib/mcollective/util/playbook/nodes/pql_nodes.rb +40 -0
  117. data/lib/mcollective/util/playbook/nodes/shell_nodes.rb +55 -0
  118. data/lib/mcollective/util/playbook/nodes/terraform_nodes.rb +65 -0
  119. data/lib/mcollective/util/playbook/nodes/yaml_nodes.rb +47 -0
  120. data/lib/mcollective/util/playbook/playbook_logger.rb +47 -0
  121. data/lib/mcollective/util/playbook/puppet_logger.rb +51 -0
  122. data/lib/mcollective/util/playbook/report.rb +152 -0
  123. data/lib/mcollective/util/playbook/task_result.rb +55 -0
  124. data/lib/mcollective/util/playbook/tasks.rb +196 -0
  125. data/lib/mcollective/util/playbook/tasks/base.rb +45 -0
  126. data/lib/mcollective/util/playbook/tasks/graphite_event_task.rb +64 -0
  127. data/lib/mcollective/util/playbook/tasks/mcollective_task.rb +356 -0
  128. data/lib/mcollective/util/playbook/tasks/shell_task.rb +93 -0
  129. data/lib/mcollective/util/playbook/tasks/slack_task.rb +105 -0
  130. data/lib/mcollective/util/playbook/tasks/webhook_task.rb +136 -0
  131. data/lib/mcollective/util/playbook/template_util.rb +98 -0
  132. data/lib/mcollective/util/playbook/uses.rb +169 -0
  133. data/lib/mcollective/util/tasks_support.rb +751 -0
  134. data/lib/mcollective/util/tasks_support/cli.rb +260 -0
  135. data/lib/mcollective/util/tasks_support/default_formatter.rb +138 -0
  136. data/lib/mcollective/util/tasks_support/json_formatter.rb +108 -0
  137. data/lib/mcollective/validator.rb +6 -1
  138. data/lib/mcollective/validator/bolt_task_name_validator.ddl +7 -0
  139. data/lib/mcollective/validator/bolt_task_name_validator.rb +11 -0
  140. data/lib/mcollective/validator/length_validator.rb +1 -3
  141. metadata +65 -6
  142. data/lib/mcollective/application/describe_filter.rb +0 -87
  143. data/lib/mcollective/matcher.rb +0 -220
  144. data/lib/mcollective/matcher/parser.rb +0 -128
  145. data/lib/mcollective/matcher/scanner.rb +0 -241
@@ -1,4 +1,4 @@
1
- class MCollective::Application::Find<MCollective::Application
1
+ class MCollective::Application::Find < MCollective::Application # rubocop:disable Style/ClassAndModuleChildren
2
2
  description "Find hosts using the discovery system matching filter criteria"
3
3
 
4
4
  def main
@@ -12,12 +12,12 @@ class MCollective::Application::Find<MCollective::Application
12
12
 
13
13
  discoverytime = Time.now - starttime
14
14
 
15
- STDERR.puts if options[:verbose]
15
+ $stderr.puts if options[:verbose]
16
16
 
17
17
  nodes.each {|c| puts c}
18
18
 
19
- STDERR.puts "\nDiscovered %s nodes in %.2f seconds using the %s discovery plugin" % [nodes.size, discoverytime, mc.client.discoverer.discovery_method] if options[:verbose]
19
+ warn "\nDiscovered %s nodes in %.2f seconds using the %s discovery plugin" % [nodes.size, discoverytime, mc.client.discoverer.discovery_method] if options[:verbose]
20
20
 
21
- nodes.size > 0 ? exit(0) : exit(1)
21
+ !nodes.empty? ? exit(0) : exit(1)
22
22
  end
23
23
  end
@@ -1,10 +1,10 @@
1
1
  module MCollective
2
- class Application::Help<Application
2
+ class Application::Help < Application # rubocop:disable Style/ClassAndModuleChildren
3
3
  description "Application list and help"
4
4
  usage "rpc help [application name]"
5
5
 
6
6
  def post_option_parser(configuration)
7
- configuration[:application] = ARGV.shift if ARGV.size > 0
7
+ configuration[:application] = ARGV.shift unless ARGV.empty?
8
8
  end
9
9
 
10
10
  def main
@@ -17,7 +17,7 @@ module MCollective
17
17
  Applications.list.sort.each do |app|
18
18
  begin
19
19
  puts " %-15s %s" % [app, Applications[app].application_description]
20
- rescue
20
+ rescue # rubocop:disable Lint/SuppressedException
21
21
  end
22
22
  end
23
23
 
@@ -1,344 +1,6 @@
1
- class MCollective::Application::Inventory<MCollective::Application
1
+ class MCollective::Application::Inventory < MCollective::Application # rubocop:disable Style/ClassAndModuleChildren
2
2
  description "General reporting tool for nodes, collectives and subcollectives"
3
3
 
4
- option :script,
5
- :description => "Script to run",
6
- :arguments => ["--script SCRIPT"]
7
-
8
- option :collectives,
9
- :description => "List all known collectives",
10
- :arguments => ["--list-collectives", "--lc"],
11
- :default => false,
12
- :type => :bool
13
-
14
- option :collectivemap,
15
- :description => "Create a DOT graph of all collectives",
16
- :arguments => ["--collective-graph MAP", "--cg MAP", "--map MAP"]
17
-
18
- def post_option_parser(configuration)
19
- configuration[:node] = ARGV.shift if ARGV.size > 0
20
- end
21
-
22
- def validate_configuration(configuration)
23
- unless configuration[:node] || configuration[:script] || configuration[:collectives] || configuration[:collectivemap]
24
- raise "Need to specify either a node name, script to run or other options"
25
- end
26
- end
27
-
28
- # Get all the known collectives and nodes that belong to them
29
- def get_collectives
30
- util = rpcclient("rpcutil")
31
- util.progress = false
32
-
33
- collectives = {}
34
- nodes = 0
35
- total = 0
36
-
37
- util.collective_info do |r, cinfo|
38
- begin
39
- if cinfo[:data] && cinfo[:data][:collectives]
40
- cinfo[:data][:collectives].each do |collective|
41
- collectives[collective] ||= []
42
- collectives[collective] << cinfo[:sender]
43
- end
44
-
45
- nodes += 1
46
- total += 1
47
- end
48
- end
49
- end
50
-
51
- {:collectives => collectives, :nodes => nodes, :total_nodes => total}
52
- end
53
-
54
- # Writes a crude DOT graph to a file
55
- def collectives_map(file)
56
- File.open(file, "w") do |graph|
57
- puts "Retrieving collective info...."
58
- collectives = get_collectives
59
-
60
- graph.puts 'graph {'
61
-
62
- collectives[:collectives].keys.sort.each do |collective|
63
- graph.puts ' subgraph "%s" {' % [ collective ]
64
-
65
- collectives[:collectives][collective].each do |member|
66
- graph.puts ' "%s" -- "%s"' % [ member, collective ]
67
- end
68
-
69
- graph.puts ' }'
70
- end
71
-
72
- graph.puts '}'
73
-
74
- puts "Graph of #{collectives[:total_nodes]} nodes has been written to #{file}"
75
- end
76
- end
77
-
78
- # Prints a report of all known sub collectives
79
- def collectives_report
80
- collectives = get_collectives
81
-
82
- puts " %-30s %s" % [ "Collective", "Nodes" ]
83
- puts " %-30s %s" % [ "==========", "=====" ]
84
-
85
- collectives[:collectives].sort_by {|key,count| count.size}.each do |collective|
86
- puts " %-30s %d" % [ collective[0], collective[1].size ]
87
- end
88
-
89
- puts
90
- puts " %30s %d" % [ "Total nodes:", collectives[:nodes] ]
91
- puts
92
- end
93
-
94
- def node_inventory
95
- node = configuration[:node]
96
-
97
- util = rpcclient("rpcutil")
98
- util.identity_filter node
99
- util.progress = false
100
-
101
- nodestats = util.custom_request("daemon_stats", {}, node, {"identity" => node}).first
102
-
103
- unless nodestats
104
- STDERR.puts "Did not receive any results from node #{node}"
105
- exit 1
106
- end
107
-
108
- unless nodestats[:statuscode] == 0
109
- STDERR.puts "Failed to retrieve daemon_stats from #{node}: #{nodestats[:statusmsg]}"
110
- else
111
- util.custom_request("inventory", {}, node, {"identity" => node}).each do |resp|
112
- unless resp[:statuscode] == 0
113
- STDERR.puts "Failed to retrieve inventory for #{node}: #{resp[:statusmsg]}"
114
- next
115
- end
116
-
117
- data = resp[:data]
118
-
119
- begin
120
- puts "Inventory for #{resp[:sender]}:"
121
- puts
122
-
123
- nodestats = nodestats[:data]
124
-
125
- puts " Server Statistics:"
126
- puts " Version: #{nodestats[:version]}"
127
- puts " Start Time: #{Time.at(nodestats[:starttime])}"
128
- puts " Config File: #{nodestats[:configfile]}"
129
- puts " Collectives: #{data[:collectives].join(', ')}" if data.include?(:collectives)
130
- puts " Main Collective: #{data[:main_collective]}" if data.include?(:main_collective)
131
- puts " Process ID: #{nodestats[:pid]}"
132
- puts " Total Messages: #{nodestats[:total]}"
133
- puts " Messages Passed Filters: #{nodestats[:passed]}"
134
- puts " Messages Filtered: #{nodestats[:filtered]}"
135
- puts " Expired Messages: #{nodestats[:ttlexpired]}"
136
- puts " Replies Sent: #{nodestats[:replies]}"
137
- puts " Total Processor Time: #{nodestats[:times][:utime]} seconds"
138
- puts " System Time: #{nodestats[:times][:stime]} seconds"
139
-
140
- puts
141
-
142
- puts " Agents:"
143
- if data[:agents].size > 0
144
- data[:agents].sort.in_groups_of(3, "") do |agents|
145
- puts " %-15s %-15s %-15s" % agents
146
- end
147
- else
148
- puts " No agents installed"
149
- end
150
-
151
- puts
152
-
153
- puts " Data Plugins:"
154
- if data[:data_plugins].size > 0
155
- data[:data_plugins].sort.in_groups_of(3, "") do |plugins|
156
- puts " %-15s %-15s %-15s" % plugins.map{|p| p.gsub("_data", "")}
157
- end
158
- else
159
- puts " No data plugins installed"
160
- end
161
-
162
- puts
163
-
164
- puts " Configuration Management Classes:"
165
- if data[:classes].size > 0
166
- field_size = MCollective::Util.field_size(data[:classes], 30)
167
- fields_num = MCollective::Util.field_number(field_size)
168
- format = " " + (" %-#{field_size}s" * fields_num)
169
-
170
- data[:classes].sort.in_groups_of(fields_num, "") do |klasses|
171
- puts format % klasses
172
- end
173
- else
174
- puts " No classes applied"
175
- end
176
-
177
- puts
178
-
179
- puts " Facts:"
180
- if data[:facts].size > 0
181
- data[:facts].sort_by{|f| f[0]}.each do |f|
182
- puts " #{f[0]} => #{f[1]}"
183
- end
184
- else
185
- puts " No facts known"
186
- end
187
-
188
- break
189
- rescue Exception => e
190
- STDERR.puts "Failed to display node inventory: #{e.class}: #{e}"
191
- end
192
- end
193
- end
194
-
195
- halt util.stats
196
- end
197
-
198
- # Helpers to create a simple DSL for scriptlets
199
- def format(fmt)
200
- @fmt = fmt
201
- end
202
-
203
- def fields(&blk)
204
- @flds = blk
205
- end
206
-
207
- def identity
208
- @node[:identity]
209
- end
210
-
211
- def facts
212
- @node[:facts]
213
- end
214
-
215
- def classes
216
- @node[:classes]
217
- end
218
-
219
- def agents
220
- @node[:agents]
221
- end
222
-
223
- def page_length(len)
224
- @page_length = len
225
- end
226
-
227
- def page_heading(fmt)
228
- @page_heading = fmt
229
- end
230
-
231
- def page_body(fmt)
232
- @page_body = fmt
233
- end
234
-
235
- # Expects a simple printf style format and apply it to
236
- # each node:
237
- #
238
- # inventory do
239
- # format "%s:\t\t%s\t\t%s"
240
- #
241
- # fields { [ identity, facts["serialnumber"], facts["productname"] ] }
242
- # end
243
- def inventory(&blk)
244
- raise "Need to give a block to inventory" unless block_given?
245
-
246
- blk.call if block_given?
247
-
248
- raise "Need to define a format" if @fmt.nil?
249
- raise "Need to define inventory fields" if @flds.nil?
250
-
251
- util = rpcclient("rpcutil")
252
- util.progress = false
253
-
254
- util.inventory do |t, resp|
255
- @node = {:identity => resp[:sender],
256
- :facts => resp[:data][:facts],
257
- :classes => resp[:data][:classes],
258
- :agents => resp[:data][:agents]}
259
-
260
- puts @fmt % @flds.call
261
- end
262
- end
263
-
264
- # Use the ruby formatr gem to build reports using Perls formats
265
- #
266
- # It is kind of ugly but brings a lot of flexibility in report
267
- # writing without building an entire reporting language.
268
- #
269
- # You need to have formatr installed to enable reports like:
270
- #
271
- # formatted_inventory do
272
- # page_length 20
273
- #
274
- # page_heading <<TOP
275
- #
276
- # Node Report @<<<<<<<<<<<<<<<<<<<<<<<<<
277
- # time
278
- #
279
- # Hostname: Customer: Distribution:
280
- # -------------------------------------------------------------------------
281
- # TOP
282
- #
283
- # page_body <<BODY
284
- #
285
- # @<<<<<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
286
- # identity, facts["customer"], facts["lsbdistdescription"]
287
- # @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
288
- # facts["processor0"]
289
- # BODY
290
- # end
291
- def formatted_inventory(&blk)
292
- require 'formatr'
293
-
294
- raise "Need to give a block to formatted_inventory" unless block_given?
295
-
296
- blk.call if block_given?
297
-
298
- raise "Need to define page body format" if @page_body.nil?
299
-
300
- body_fmt = FormatR::Format.new(@page_heading, @page_body)
301
- body_fmt.setPageLength(@page_length)
302
- time = Time.now
303
-
304
- util = rpcclient("rpcutil")
305
- util.progress = false
306
-
307
- util.inventory do |t, resp|
308
- @node = {:identity => resp[:sender],
309
- :facts => resp[:data][:facts],
310
- :classes => resp[:data][:classes],
311
- :agents => resp[:data][:agents]}
312
-
313
- body_fmt.printFormat(binding)
314
- end
315
- rescue Exception => e
316
- STDERR.puts "Could not create report: #{e.class}: #{e}"
317
- exit 1
318
- end
319
-
320
- @fmt = nil
321
- @flds = nil
322
- @page_heading = nil
323
- @page_body = nil
324
- @page_length = 40
325
-
326
- def main
327
- if configuration[:script]
328
- if File.exist?(configuration[:script])
329
- eval(File.read(configuration[:script]))
330
- else
331
- raise "Could not find script to run: #{configuration[:script]}"
332
- end
333
-
334
- elsif configuration[:collectivemap]
335
- collectives_map(configuration[:collectivemap])
336
-
337
- elsif configuration[:collectives]
338
- collectives_report
339
-
340
- else
341
- node_inventory
342
- end
343
- end
4
+ external(:command => "choria", :args => ["inventory"])
5
+ external_help(:command => "choria", :args => ["inventory", "--help"])
344
6
  end
@@ -1,52 +1,6 @@
1
- # encoding: utf-8
2
1
  module MCollective
3
- class Application::Ping<Application
4
- description "Ping all nodes"
5
-
6
- option :graph,
7
- :description => "Shows a graph of ping distribution",
8
- :arguments => ["--graph", "-g"],
9
- :default => false,
10
- :type => :bool
11
-
12
- # Convert the times structure into a array representing
13
- # buckets of responses in 50 ms intervals. Return a small
14
- # sparkline graph using UTF8 characters
15
- def spark(resp_times)
16
- return "" unless configuration[:graph] || Config.instance.pluginconf["rpc.graph"]
17
-
18
- ticks=%w[▁ ▂ ▃ ▄ ▅ ▆ ▇]
19
-
20
- histo = {}
21
-
22
- # round each time to its nearest 50ms
23
- # and keep a count for each 50ms
24
- resp_times.each do |time|
25
- time = Integer(time + 50 - (time % 50))
26
- histo[time] ||= 0
27
- histo[time] += 1
28
- end
29
-
30
- # set the 50ms intervals that saw no traffic to 0
31
- ((histo.keys.max - histo.keys.min) / 50).times do |i|
32
- time = (i * 50) + histo.keys.min
33
- histo[time] = 0 unless histo[time]
34
- end
35
-
36
- # get a numerically sorted list of times
37
- histo = histo.keys.sort.map{|k| histo[k]}
38
-
39
- range = histo.max - histo.min
40
- scale = ticks.size - 1
41
- distance = histo.max.to_f / scale
42
-
43
- histo.map do |val|
44
- tick = (val / distance).round
45
- tick = 0 if tick < 0
46
-
47
- ticks[tick]
48
- end.join
49
- end
2
+ class Application::Ping < Application # rubocop:disable Style/ClassAndModuleChildren
3
+ description "Low level network connectivity test"
50
4
 
51
5
  def main
52
6
  # If the user did not override the default timeout include the discovery timeout
@@ -67,11 +21,11 @@ module MCollective
67
21
 
68
22
  puts("\n\n---- ping statistics ----")
69
23
 
70
- if times.size > 0
71
- sum = times.inject(0){|acc,i|acc +i}
24
+ if !times.empty?
25
+ sum = times.inject(0) {|acc, i| acc + i}
72
26
  avg = sum / times.length.to_f
73
27
 
74
- puts "%d replies max: %.2f min: %.2f avg: %.2f %s" % [times.size, times.max, times.min, avg, spark(times)]
28
+ puts "%d replies max: %.2f min: %.2f avg: %.2f" % [times.size, times.max, times.min, avg]
75
29
  else
76
30
  puts("No responses received")
77
31
  end