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, line 5
def initialize
    @starttime = Time.now.to_i
    @validated = 0
    @unvalidated = 0
    @filtered = 0
    @passed = 0
    @total = 0
    @replies = 0

    @mutex = Mutex.new
end

Public Instance Methods

filtered() click to toggle source

Records a message that didnt pass the filters

# File lib/mcollective/runnerstats.rb, line 24
def filtered
    Log.debug("Incrementing filtered stat")
    @filtered += 1
end
passed() click to toggle source

Records a message that passed the filters

# File lib/mcollective/runnerstats.rb, line 18
def passed
    Log.debug("Incrementing passed stat")
    @passed += 1
end
received() click to toggle source

Records receipt of a message

# File lib/mcollective/runnerstats.rb, line 41
def received
    Log.debug("Incrementing total stat")
    @total += 1
end
sent() click to toggle source

Records sending a message

# File lib/mcollective/runnerstats.rb, line 47
def sent
    @mutex.synchronize do
        Log.debug("Incrementing replies stat")
        @replies += 1
    end
end
to_hash() click to toggle source

Returns a hash with all stats

# File lib/mcollective/runnerstats.rb, line 55
def to_hash
    stats = {:validated => @validated,
             :unvalidated => @unvalidated,
             :passed => @passed,
             :filtered => @filtered,
             :starttime => @starttime,
             :total => @total,
             :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}"
    end

    reply[:agents] = Agents.agentlist
    reply
end
unvalidated() click to toggle source
# File lib/mcollective/runnerstats.rb, line 35
def unvalidated
    Log.debug("Incrementing unvalidated stat")
    @unvalidated += 1
end
validated() click to toggle source

Records a message that validated ok

# File lib/mcollective/runnerstats.rb, line 30
def validated
    Log.debug("Incrementing validated stat")
    @validated += 1
end