File: process.rb

package info (click to toggle)
ruby-serverspec 2.42.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 980 kB
  • sloc: ruby: 4,835; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 590 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Serverspec::Type
  class Process < Base
    def running?
      pid = @runner.get_process(@name, :format => "pid=").stdout
      not pid.empty?
    end

    def user
      get_column("user")
    end

    def group
      get_column("group")
    end

    def count
      @runner.count_process(@name).stdout.strip.to_i
    end

    def method_missing(meth)
      get_column(meth.to_s)
    end

    def get_column(keyword)
      ret = @runner.get_process(@name, :format => "#{keyword}=")
      val = ret.stdout.strip
      val = val.to_i if val.match(/^\d+$/)
      val
    end
  end
end