PortablePoller
# 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
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
# 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
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
Generated with the Darkfish Rdoc Generator 2.