class MCollective::RunnerStats - mcollective version 2.12.5

# class MCollective::RunnerStats

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

### Public Class Methods

new() click to toggle source

       # File lib/mcollective/runnerstats.rb
     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

### Public Instance Methods

filtered() click to toggle source

Records a message that didnt pass the filters

       # File lib/mcollective/runnerstats.rb
    31 def filtered
    32   Log.debug("Incrementing filtered stat")
    33   @filtered += 1
    34 end

passed() click to toggle source

Records a message that passed the filters

       # File lib/mcollective/runnerstats.rb
    25 def passed
    26   Log.debug("Incrementing passed stat")
    27   @passed += 1
    28 end

received() click to toggle source

Records receipt of a message

       # File lib/mcollective/runnerstats.rb
    48 def received
    49   Log.debug("Incrementing total stat")
    50   @total += 1
    51 end

sent() click to toggle source

Records sending a message

       # File lib/mcollective/runnerstats.rb
    54 def sent
    55   @mutex.synchronize do
    56     Log.debug("Incrementing replies stat")
    57     @replies += 1
    58   end
    59 end

to_hash() click to toggle source

Returns a hash with all stats

       # File lib/mcollective/runnerstats.rb
    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

ttlexpired() click to toggle source

Records a message that failed TTL checks

       # File lib/mcollective/runnerstats.rb
    19 def ttlexpired
    20   Log.debug("Incrementing ttl expired stat")
    21   @ttlexpired += 1
    22 end

unvalidated() click to toggle source

       # File lib/mcollective/runnerstats.rb
    42 def unvalidated
    43   Log.debug("Incrementing unvalidated stat")
    44   @unvalidated += 1
    45 end

validated() click to toggle source

Records a message that validated ok

       # File lib/mcollective/runnerstats.rb
    37 def validated
    38   Log.debug("Incrementing validated stat")
    39   @validated += 1
    40 end