Sha256: 530d278c6942a39bcccfa848333fef4992e529b96ba23ae1e9b2c5013a59f8d9

Contents?: true

Size: 813 Bytes

Versions: 50

Compression:

Stored size: 813 Bytes

Contents

module God
  module System
  
    class Process
      def initialize(pid)
        @pid = pid.to_i
        @poller = fetch_system_poller.new(@pid)
      end
      
      # Return true if this process is running, false otherwise
      def exists?
        !!::Process.kill(0, @pid) rescue false
      end
      
      # Memory usage in kilobytes (resident set size)
      def memory
        @poller.memory
      end
      
      # Percentage memory usage
      def percent_memory
        @poller.percent_memory
      end
      
      # Percentage CPU usage
      def percent_cpu
        @poller.percent_cpu
      end
      
      private
      
      def fetch_system_poller
        if SlashProcPoller.usable?
          SlashProcPoller
        else
          PortablePoller
        end
      end
    end
  
  end
end

Version data entries

50 entries across 50 versions & 19 rubygems

Version Path
dguettler-god-0.7.13.2 lib/god/system/process.rb
dguettler-god-0.7.13.3 lib/god/system/process.rb
dosire-god-0.7.10 lib/god/system/process.rb
dosire-god-0.7.12 lib/god/system/process.rb
dosire-god-0.7.9 lib/god/system/process.rb
dunedain289-god-0.7.12.1 lib/god/system/process.rb
dustin-god-0.7.7.1 lib/god/system/process.rb
eric-god-0.7.10 lib/god/system/process.rb
eric-god-0.7.11 lib/god/system/process.rb
eric-god-0.7.12 lib/god/system/process.rb
eric-god-0.7.14 lib/god/system/process.rb
eric-god-0.7.7 lib/god/system/process.rb
fotonauts-god-0.7.10 lib/god/system/process.rb
fotonauts-god-0.7.12 lib/god/system/process.rb
gohanlonllc-god-0.7.9 lib/god/system/process.rb
gordoncww-god-0.7.11.1 lib/god/system/process.rb
jreynolds-god-0.7.13 lib/god/system/process.rb
jwilkins-god-0.7.9 lib/god/system/process.rb
mathieuravaux-god-0.7.11 lib/god/system/process.rb
mojombo-god-0.7.10 lib/god/system/process.rb