Class: MCollective::RunnerStats
- Inherits:
-
Object
- Object
- MCollective::RunnerStats
- Defined in:
- lib/mcollective/runnerstats.rb
Overview
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
Instance Method Summary collapse
-
#filtered ⇒ Object
Records a message that didnt pass the filters.
-
#initialize ⇒ RunnerStats
constructor
A new instance of RunnerStats.
-
#passed ⇒ Object
Records a message that passed the filters.
-
#received ⇒ Object
Records receipt of a message.
-
#sent ⇒ Object
Records sending a message.
-
#to_hash ⇒ Object
Returns a hash with all stats.
-
#ttlexpired ⇒ Object
Records a message that failed TTL checks.
- #unvalidated ⇒ Object
-
#validated ⇒ Object
Records a message that validated ok.
Constructor Details
#initialize ⇒ RunnerStats
Returns a new instance of RunnerStats.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/mcollective/runnerstats.rb', line 5 def initialize @starttime = Time.now.to_i @validated = 0 @unvalidated = 0 @filtered = 0 @passed = 0 @total = 0 @replies = 0 @ttlexpired = 0 @mutex = Mutex.new end |
Instance Method Details
#filtered ⇒ Object
Records a message that didnt pass the filters
31 32 33 34 |
# File 'lib/mcollective/runnerstats.rb', line 31 def filtered Log.debug("Incrementing filtered stat") @filtered += 1 end |
#passed ⇒ Object
Records a message that passed the filters
25 26 27 28 |
# File 'lib/mcollective/runnerstats.rb', line 25 def passed Log.debug("Incrementing passed stat") @passed += 1 end |
#received ⇒ Object
Records receipt of a message
48 49 50 51 |
# File 'lib/mcollective/runnerstats.rb', line 48 def received Log.debug("Incrementing total stat") @total += 1 end |
#sent ⇒ Object
Records sending a message
54 55 56 57 58 59 |
# File 'lib/mcollective/runnerstats.rb', line 54 def sent @mutex.synchronize do Log.debug("Incrementing replies stat") @replies += 1 end end |
#to_hash ⇒ Object
Returns a hash with all stats
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/mcollective/runnerstats.rb', line 62 def to_hash stats = { :validated => @validated, :unvalidated => @unvalidated, :passed => @passed, :filtered => @filtered, :starttime => @starttime, :total => @total, :ttlexpired => @ttlexpired, :replies => @replies } reply = { :stats => stats, :threads => [], :pid => Process.pid, :times => {} } ::Process.times.each_pair {|k, v| k = k.to_sym reply[:times][k] = v } Thread.list.each do |t| reply[:threads] << t.inspect.to_s end reply[:agents] = Agents.agentlist reply end |
#ttlexpired ⇒ Object
Records a message that failed TTL checks
19 20 21 22 |
# File 'lib/mcollective/runnerstats.rb', line 19 def ttlexpired Log.debug("Incrementing ttl expired stat") @ttlexpired += 1 end |