| Class | MCollective::RunnerStats |
| In: |
lib/mcollective/runnerstats.rb
|
| Parent: | Object |
Class to store stats about the mcollectived, it should live in the PluginManager so that agents etc can get hold of it and return the stats to callers
# File lib/mcollective/runnerstats.rb, line 5
5: def initialize
6: @starttime = Time.now.to_i
7: @validated = 0
8: @unvalidated = 0
9: @filtered = 0
10: @passed = 0
11: @total = 0
12: @replies = 0
13:
14: @mutex = Mutex.new
15:
16: @logger = Log.instance
17: end
Records a message that didnt pass the filters
# File lib/mcollective/runnerstats.rb, line 26
26: def filtered
27: @logger.debug("Incrementing filtered stat")
28: @filtered += 1
29: end
Records receipt of a message
# File lib/mcollective/runnerstats.rb, line 43
43: def received
44: @logger.debug("Incrementing total stat")
45: @total += 1
46: end
Records sending a message
# File lib/mcollective/runnerstats.rb, line 49
49: def sent
50: @mutex.synchronize do
51: @logger.debug("Incrementing replies stat")
52: @replies += 1
53: end
54: end
Returns a hash with all stats
# File lib/mcollective/runnerstats.rb, line 57
57: def to_hash
58: stats = {:validated => @validated,
59: :unvalidated => @unvalidated,
60: :passed => @passed,
61: :filtered => @filtered,
62: :starttime => @starttime,
63: :total => @total,
64: :replies => @replies}
65:
66: reply = {:stats => stats,
67: :threads => [],
68: :pid => Process.pid,
69: :times => {} }
70:
71: ::Process.times.each_pair{|k,v|
72: k = k.to_sym
73: reply[:times][k] = v
74: }
75:
76: Thread.list.each do |t|
77: reply[:threads] << "#{t.inspect}"
78: end
79:
80: reply[:agents] = Agents.agentlist
81: reply
82: end
# File lib/mcollective/runnerstats.rb, line 37
37: def unvalidated
38: @logger.debug("Incrementing unvalidated stat")
39: @unvalidated += 1
40: end