Class MCollective::Application::Ping
In: plugins/mcollective/application/ping.rb
Parent: Application

Methods

main  

Public Instance methods

[Source]

    # File plugins/mcollective/application/ping.rb, line 5
 5:         def main
 6:             client = MCollective::Client.new(options[:config])
 7:             client.options = options
 8: 
 9:             start = Time.now.to_f
10:             times = []
11: 
12:             client.req("ping", "discovery") do |resp|
13:                 times << (Time.now.to_f - start) * 1000
14: 
15:                 printf("%-40s time=%.2f ms\n", resp[:senderid], times.last)
16:             end
17: 
18:             puts("\n\n---- ping statistics ----")
19: 
20:             if times.size > 0
21:                 sum = times.inject(0){|acc,i|acc +i}
22:                 avg = sum / times.length.to_f
23: 
24:                 printf("%d replies max: %.2f min: %.2f avg: %.2f\n", times.size, times.max, times.min, avg)
25:             else
26:                 puts("No responses received")
27:             end
28:         end

[Validate]