process_monitor 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -0
  2. data/VERSION +1 -1
  3. data/lib/process_monitor.rb +15 -6
  4. metadata +4 -4
data/Rakefile CHANGED
@@ -8,6 +8,7 @@ begin
8
8
  gemspec.summary = "A gem to monitor processes"
9
9
  gemspec.description = "This gem gets the status(running/sleeping/defunct) based on a pattern you provide to it. For example if you have a service which is running and its a ruby service you would need to pass the type(ruby) and a pattern which would identify the process."
10
10
  gemspec.email = "sriram.varahan@gmail.com"
11
+ gemspec.homepage = "http://github.com/sriram/Process-Monitor"
11
12
  gemspec.authors = ["Sriram Varahan"]
12
13
  end
13
14
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -1,5 +1,9 @@
1
1
  class ProcessMonitor
2
-
2
+
3
+ ##
4
+ # This method fetches the process ids of the process matching the process_type and
5
+ # process_pattern
6
+ #
3
7
  def self.get_pid(process_type,process_pattern="")
4
8
  # Parse the output to fetch the process id.
5
9
  process_id_reg_exp = %r{^(.*)\s*}
@@ -25,15 +29,24 @@ class ProcessMonitor
25
29
  end
26
30
 
27
31
 
32
+ ##
33
+ # Gets the process status given the process id
34
+ #
28
35
  def self.get_process_status(pid=nil)
29
36
  unless pid.nil?
30
- `cat /proc/#{pid}/status|grep State`
37
+ status_regexp = %r{\s\((.*)\)\n}
38
+ complete_status = `cat /proc/#{pid}/status|grep State`
39
+ status_regexp.match(complete_status)
40
+ status = $1.capitalize
31
41
  else
32
42
  p "No pid given!"
33
43
  end
34
44
  end
35
45
 
36
46
 
47
+ ##
48
+ # Returns true if the process is up else returns false.
49
+ #
37
50
  def self.process_is_up?(pid)
38
51
  unless pid.nil?
39
52
  # The folder /proc/<pid>/ contains information about the process
@@ -46,7 +59,3 @@ class ProcessMonitor
46
59
  end
47
60
 
48
61
  end
49
-
50
-
51
-
52
-
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_monitor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sriram Varahan
@@ -34,7 +34,7 @@ files:
34
34
  - VERSION
35
35
  - lib/process_monitor.rb
36
36
  has_rdoc: true
37
- homepage:
37
+ homepage: http://github.com/sriram/Process-Monitor
38
38
  licenses: []
39
39
 
40
40
  post_install_message: