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: end
Records a message that didnt pass the filters
# File lib/mcollective/runnerstats.rb, line 24 24: def filtered 25: Log.debug("Incrementing filtered stat") 26: @filtered += 1 27: end
Records receipt of a message
# File lib/mcollective/runnerstats.rb, line 41 41: def received 42: Log.debug("Incrementing total stat") 43: @total += 1 44: end
Records sending a message
# File lib/mcollective/runnerstats.rb, line 47 47: def sent 48: @mutex.synchronize do 49: Log.debug("Incrementing replies stat") 50: @replies += 1 51: end 52: end
Returns a hash with all stats
# File lib/mcollective/runnerstats.rb, line 55 55: def to_hash 56: stats = {:validated => @validated, 57: :unvalidated => @unvalidated, 58: :passed => @passed, 59: :filtered => @filtered, 60: :starttime => @starttime, 61: :total => @total, 62: :replies => @replies} 63: 64: reply = {:stats => stats, 65: :threads => [], 66: :pid => Process.pid, 67: :times => {} } 68: 69: ::Process.times.each_pair{|k,v| 70: k = k.to_sym 71: reply[:times][k] = v 72: } 73: 74: Thread.list.each do |t| 75: reply[:threads] << "#{t.inspect}" 76: end 77: 78: reply[:agents] = Agents.agentlist 79: reply 80: end
# File lib/mcollective/runnerstats.rb, line 35 35: def unvalidated 36: Log.debug("Incrementing unvalidated stat") 37: @unvalidated += 1 38: end