Class: Stalin::Watcher::UnixPs

Inherits:
Object
  • Object
show all
Defined in:
lib/stalin/watcher/unix_ps.rb

Instance Method Summary collapse

Constructor Details

#initialize(pid) ⇒ UnixPs

Returns a new instance of UnixPs.

Parameters:

  • pid (Integer)

    target process ID

Raises:



5
6
7
8
9
10
11
12
13
# File 'lib/stalin/watcher/unix_ps.rb', line 5

def initialize(pid)
  begin
    ps(Process.pid)
  rescue StandardError => e
    raise Stalin::Unsupported, "ps failed: #{e.message}"
  end

  @pid = pid
end

Instance Method Details

#watchInteger?

Report on memory usage.

Returns:

  • (Integer, nil)

    target process’ memory usage in bytes, nil if process not found



18
19
20
21
22
# File 'lib/stalin/watcher/unix_ps.rb', line 18

def watch
  ps(@pid)
rescue ArgumentError
  nil
end