| 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: @ttlexpired = 0
14:
15: @mutex = Mutex.new
16: end
Records a message that didnt pass the filters
# File lib/mcollective/runnerstats.rb, line 31
31: def filtered
32: Log.debug("Incrementing filtered stat")
33: @filtered += 1
34: end
Records receipt of a message
# File lib/mcollective/runnerstats.rb, line 48
48: def received
49: Log.debug("Incrementing total stat")
50: @total += 1
51: end
Records sending a message
# File lib/mcollective/runnerstats.rb, line 54
54: def sent
55: @mutex.synchronize do
56: Log.debug("Incrementing replies stat")
57: @replies += 1
58: end
59: end
Returns a hash with all stats
# File lib/mcollective/runnerstats.rb, line 62
62: def to_hash
63: stats = {:validated => @validated,
64: :unvalidated => @unvalidated,
65: :passed => @passed,
66: :filtered => @filtered,
67: :starttime => @starttime,
68: :total => @total,
69: :ttlexpired => @ttlexpired,
70: :replies => @replies}
71:
72: reply = {:stats => stats,
73: :threads => [],
74: :pid => Process.pid,
75: :times => {} }
76:
77: ::Process.times.each_pair{|k,v|
78: k = k.to_sym
79: reply[:times][k] = v
80: }
81:
82: Thread.list.each do |t|
83: reply[:threads] << "#{t.inspect}"
84: end
85:
86: reply[:agents] = Agents.agentlist
87: reply
88: end
Records a message that failed TTL checks
# File lib/mcollective/runnerstats.rb, line 19
19: def ttlexpired
20: Log.debug("Incrementing ttl expired stat")
21: @ttlexpired += 1
22: end
# File lib/mcollective/runnerstats.rb, line 42
42: def unvalidated
43: Log.debug("Incrementing unvalidated stat")
44: @unvalidated += 1
45: end