Parent

Files

Class/Module Index [+]

Quicksearch

God::System::SlashProcPoller

Public Class Methods

new(pid) click to toggle source
# File lib/god/system/slash_proc_poller.rb, line 22
def initialize(pid)
  super(pid)

  unless @@total_mem # in K
    File.open(MeminfoPath) do |f|
      @@total_mem = f.gets.split[1]
    end
  end
end
usable?() click to toggle source

FreeBSD has /proc by default, but nothing mounted there! So we should check for the actual required paths! Returns true if RequiredPaths are readable.

# File lib/god/system/slash_proc_poller.rb, line 16
def self.usable?
  RequiredPaths.all? do |path|
    test(rr, path) && readable?(path)
  end
end

Public Instance Methods

memory() click to toggle source
# File lib/god/system/slash_proc_poller.rb, line 32
def memory
  stat[:rss].to_i * @@kb_per_page
rescue # This shouldn't fail is there's an error (or proc doesn't exist)
  0
end
percent_cpu() click to toggle source

TODO: Change this to calculate the wma instead

# File lib/god/system/slash_proc_poller.rb, line 45
def percent_cpu
  stats = stat
  total_time = stats[:utime].to_i + stats[:stime].to_i # in jiffies
  seconds = uptime - stats[:starttime].to_i / @@hertz
  if seconds == 0
    0
  else
    ((total_time * 1000 / @@hertz) / seconds) / 10
  end
rescue # This shouldn't fail is there's an error (or proc doesn't exist)
  0
end
percent_memory() click to toggle source
# File lib/god/system/slash_proc_poller.rb, line 38
def percent_memory
  (memory / @@total_mem.to_f) * 100
rescue # This shouldn't fail is there's an error (or proc doesn't exist)
  0
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.