Class: Titan::System

Inherits:
Object
  • Object
show all
Defined in:
lib/titan/system.rb

Class Method Summary collapse

Class Method Details

.check_filesystemObject

Checks the file system for neccessary directories and permissions



24
25
26
# File 'lib/titan/system.rb', line 24

def check_filesystem
  Dir.mkdir(Titan::TITAN_DIRECTORY) unless File.directory?(Titan::TITAN_DIRECTORY)
end

.pid_filesObject

Returns a list of all pid files available in the Titan::TITAN_DIRECTORY



31
32
33
# File 'lib/titan/system.rb', line 31

def pid_files
  Dir.entries(Titan::TITAN_DIRECTORY) - [".", ".."]
end

.ps(command, pid) ⇒ Object

Calls the ps function of the OS with a given command and process id

E.g., if you want to get the used memory of a given process (pid=10), you can do this by:

Titan::System.ps('rss', 10).to_i


13
14
15
16
17
18
19
# File 'lib/titan/system.rb', line 13

def ps(command, pid)
  if pid > 0
    `ps -o #{command}= -p #{pid}`
  else
    nil
  end
end