workaholic-cron 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/workaholic.rb +3 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0297d803d19049bb9c2d489c1b93db2b45ae8fa
|
4
|
+
data.tar.gz: 0b689792a2a112c9ccb16c144afe1ebc74fdf9d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 810dc5e91ab142225315cf64e5514eb7ff933b5db7b8f1d3dbae196cfb7df5212a24502ef60c54d29e3e1a9cfed208a4ea5139afcdef94785dabe82f5978c2f4
|
7
|
+
data.tar.gz: 247eea18bb7b5e030f5f44e22b16fbe10a4fc0d27e27a481fd6ee47dc54b92698cf846bfc5683b7f937a8911e19bedf5c1119998f6d468d5497d4b8bb4a50a04
|
data/lib/workaholic.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
#!/bin/ruby
|
2
|
-
require 'time'
|
3
|
-
|
4
2
|
class Workaholic
|
5
3
|
# Find long running cron jobs.
|
6
4
|
#
|
@@ -8,7 +6,7 @@ class Workaholic
|
|
8
6
|
# >> require 'workaholic'
|
9
7
|
# >> workers = Workaholic.new 'cron', 300
|
10
8
|
# >> workers.scan
|
11
|
-
# =>
|
9
|
+
# => {:"4389"=>71983, :"4335"=>71994}
|
12
10
|
#
|
13
11
|
# Arguments:
|
14
12
|
# proccess: (String)
|
@@ -22,11 +20,11 @@ class Workaholic
|
|
22
20
|
|
23
21
|
def scan
|
24
22
|
# Get all child processes of the desired parent process.
|
25
|
-
pids = %x(ps -o pid,etime --ppid=`pidof -s #{proccess}` --sort=etime | awk '{print $1,$2}' | tr '-' ' ' | awk '{print $1,$3}' | egrep '^[0-9]' | grep ':')
|
23
|
+
pids = %x(ps -o pid,etime --ppid=`pidof -s #{@proccess}` --sort=etime | awk '{print $1,$2}' | tr '-' ' ' | awk '{print $1,$3}' | egrep '^[0-9]' | grep ':')
|
26
24
|
workaholics = {}
|
27
25
|
pids.each_line do |proccess|
|
28
26
|
pid, etime = proccess.split
|
29
|
-
workaholics[pid.to_sym] = etime_to_i etime if (etime_to_i etime) > limit
|
27
|
+
workaholics[pid.to_sym] = etime_to_i etime if (etime_to_i etime) > @limit
|
30
28
|
end
|
31
29
|
workaholics
|
32
30
|
end
|