rbbt-util 5.13.25 → 5.13.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbbt +2 -2
- data/lib/rbbt/monitor.rb +83 -0
- data/lib/rbbt/util/log.rb +6 -2
- data/lib/rbbt/util/misc/concurrent_stream.rb +1 -1
- data/share/rbbt_commands/system/clean +96 -0
- data/share/rbbt_commands/system/status +105 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 109a367647ca3e97bdd9cd9c7951f1dea64045d5
|
4
|
+
data.tar.gz: 0fc762047146427ce7dd94eddb4a8b7a05616cda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8be51c3acb036f80bba3c2cb9082244eecb1dc06892da9322ff8b1d813f99b2233bb34176590ae671a3632d031cc2c6220568f19829c4c9701907c7ec5bf0d76
|
7
|
+
data.tar.gz: 55a3431a1e466e2b0aeb7d742592d9a24f9a69c1c4c15697c33b675dd4cd87c3f981627c476ef38adb85100a6b811d0329bd784a31c7faa96461cd0dfd541c57
|
data/bin/rbbt
CHANGED
data/lib/rbbt/monitor.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'rbbt'
|
2
|
+
|
3
|
+
module Rbbt
|
4
|
+
|
5
|
+
LOCK_DIRS = Rbbt.share.find_all + Rbbt.var.cache.persistence.find_all + Rbbt.tmp.tsv_open_locks.find_all + Rbbt.var.jobs.find_all
|
6
|
+
def self.locks(dirs = LOCK_DIRS)
|
7
|
+
dirs.collect do |dir|
|
8
|
+
dir.glob("**/*.lock")
|
9
|
+
end.flatten
|
10
|
+
end
|
11
|
+
|
12
|
+
SENSIBLE_WRITE_DIRS = Misc.sensiblewrite_dir.find_all
|
13
|
+
def self.sensiblewrites(dirs = SENSIBLE_WRITE_DIRS)
|
14
|
+
dirs.collect do |dir|
|
15
|
+
dir.glob("**/*").reject{|f| f =~ /\.lock$/ }
|
16
|
+
end.flatten
|
17
|
+
end
|
18
|
+
|
19
|
+
PERSIST_DIRS = Rbbt.share.find_all + Rbbt.var.cache.persistence.find_all
|
20
|
+
def self.persists(dirs = PERSIST_DIRS)
|
21
|
+
dirs.collect do |dir|
|
22
|
+
dir.glob("**/*.persist").reject{|f| f =~ /\.lock$/ }
|
23
|
+
end.flatten
|
24
|
+
end
|
25
|
+
|
26
|
+
JOB_DIRS = Rbbt.var.jobs.find_all
|
27
|
+
def self.jobs(dirs = JOB_DIRS)
|
28
|
+
job_files = {}
|
29
|
+
dirs.each do |dir|
|
30
|
+
workflow_dirs = dir.glob("*").each do |wdir|
|
31
|
+
workflow = File.basename(wdir)
|
32
|
+
job_files[workflow] = {}
|
33
|
+
task_dirs = wdir.glob('*')
|
34
|
+
task_dirs.each do |tdir|
|
35
|
+
task = File.basename(tdir)
|
36
|
+
job_files[workflow][task] = tdir.glob('*')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
jobs = {}
|
41
|
+
job_files.each do |workflow,task_jobs|
|
42
|
+
jobs[workflow] ||= {}
|
43
|
+
task_jobs.each do |task, files|
|
44
|
+
jobs[workflow][task] ||= {}
|
45
|
+
files.each do |f|
|
46
|
+
next if f =~ /\.lock$/
|
47
|
+
job = f.sub(/\.(info|files)/,'')
|
48
|
+
|
49
|
+
jobs[workflow][task][job] ||= {}
|
50
|
+
if jobs[workflow][task][job][:status].nil?
|
51
|
+
status = nil
|
52
|
+
status = :done if Open.exists? job
|
53
|
+
if status.nil? and f=~/\.info/
|
54
|
+
info = begin
|
55
|
+
Step::INFO_SERIALIAZER.load(Open.read(f, :mode => 'rb'))
|
56
|
+
rescue
|
57
|
+
{}
|
58
|
+
end
|
59
|
+
status = info[:status]
|
60
|
+
pid = info[:pid]
|
61
|
+
end
|
62
|
+
|
63
|
+
jobs[workflow][task][job][:pid] = pid if pid
|
64
|
+
jobs[workflow][task][job][:status] = status if status
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
jobs
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.load_lock(lock)
|
73
|
+
begin
|
74
|
+
info = Misc.insist 3 do
|
75
|
+
YAML.load(Open.read(lock))
|
76
|
+
end
|
77
|
+
info.values_at "pid", "ppid", "time"
|
78
|
+
rescue Exception
|
79
|
+
[nil, nil, File.atime(lock)]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/lib/rbbt/util/log.rb
CHANGED
@@ -53,8 +53,12 @@ module Log
|
|
53
53
|
|
54
54
|
self.ignore_stderr do
|
55
55
|
require 'nokogiri'
|
56
|
-
|
57
|
-
|
56
|
+
self.tty_size = begin
|
57
|
+
require "highline/system_extensions.rb"
|
58
|
+
HighLine::SystemExtensions.terminal_size.first
|
59
|
+
rescue Exception
|
60
|
+
nil
|
61
|
+
end
|
58
62
|
end
|
59
63
|
|
60
64
|
def self.with_severity(level)
|
@@ -96,7 +96,7 @@ module ConcurrentStream
|
|
96
96
|
@aborted = false if t == Thread.current
|
97
97
|
next if t == Thread.current
|
98
98
|
Log.medium "Aborting thread #{t.inspect}"
|
99
|
-
t.raise Aborted.new "
|
99
|
+
t.raise Aborted.new "From step: #{path}"
|
100
100
|
end if @threads
|
101
101
|
|
102
102
|
sleeped = false
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbbt-util'
|
4
|
+
require 'rbbt/util/simpleopt'
|
5
|
+
require 'rbbt/workflow'
|
6
|
+
require 'rbbt/monitor'
|
7
|
+
|
8
|
+
$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
|
9
|
+
|
10
|
+
options = SOPT.setup <<EOF
|
11
|
+
|
12
|
+
Clean failed jobs, lock files, etc
|
13
|
+
|
14
|
+
$ rbbt system clean
|
15
|
+
|
16
|
+
-h--help Print this help
|
17
|
+
EOF
|
18
|
+
rbbt_usage and exit 0 if options[:help]
|
19
|
+
|
20
|
+
locks = Rbbt.locks
|
21
|
+
sensiblewrites = Rbbt.sensiblewrites
|
22
|
+
persists = Rbbt.persists
|
23
|
+
|
24
|
+
puts Log.color(:magenta, "# System clean")
|
25
|
+
puts
|
26
|
+
if locks.any?
|
27
|
+
puts Log.color(:magenta, "Locks: #{locks.length}")
|
28
|
+
locks.each do |lock|
|
29
|
+
pid, ppid, time = Rbbt.load_lock(lock)
|
30
|
+
if not Misc.pid_exists? pid
|
31
|
+
puts " Removing #{ lock }"
|
32
|
+
FileUtils.rm lock
|
33
|
+
end
|
34
|
+
end
|
35
|
+
puts
|
36
|
+
end
|
37
|
+
|
38
|
+
if persists.any?
|
39
|
+
puts Log.color(:magenta, "Persist: #{persists.length}")
|
40
|
+
persists.each do |persist|
|
41
|
+
lf = persist + '.lock'
|
42
|
+
pid, ppid, time = Rbbt.load_lock(lf)
|
43
|
+
if not Misc.pid_exists? pid
|
44
|
+
puts " Removing #{ persist }"
|
45
|
+
FileUtils.rm persists
|
46
|
+
FileUtils.rm lf
|
47
|
+
end
|
48
|
+
end
|
49
|
+
puts
|
50
|
+
end
|
51
|
+
|
52
|
+
if sensiblewrites.any?
|
53
|
+
puts Log.color(:magenta, "Writing: #{sensiblewrites.length}")
|
54
|
+
sensiblewrites.each do |sensiblewrite|
|
55
|
+
lf = sensiblewrite + '.lock'
|
56
|
+
pid, ppid, time = Rbbt.load_lock(lf)
|
57
|
+
if not Misc.pid_exists? pid
|
58
|
+
puts " Removing #{ sensiblewrite }"
|
59
|
+
FileUtils.rm sensiblewrite
|
60
|
+
FileUtils.rm lf
|
61
|
+
end
|
62
|
+
end
|
63
|
+
puts
|
64
|
+
end
|
65
|
+
|
66
|
+
jobs = Rbbt.jobs
|
67
|
+
|
68
|
+
puts Log.color(:magenta, "# Workflows:")
|
69
|
+
puts
|
70
|
+
jobs.each do |workflow, tasks|
|
71
|
+
tasks.each do |task, jobs|
|
72
|
+
puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:yellow, task) << ": #{jobs.length}"
|
73
|
+
done = []
|
74
|
+
other = {}
|
75
|
+
jobs.each do |file,h|
|
76
|
+
status = h[:status]
|
77
|
+
if h[:status] == :done
|
78
|
+
done << file
|
79
|
+
else
|
80
|
+
other[status||"missing"] ||= []
|
81
|
+
other[status||"missing"] << [file, h[:pid]]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
other.each do |status, list|
|
85
|
+
list.each do |f,p|
|
86
|
+
if not Misc.pid_exists?(p) or status.to_s =~ /error|aborted|missing/
|
87
|
+
puts " Removing #{ f }"
|
88
|
+
FileUtils.rm_rf f
|
89
|
+
FileUtils.rm_rf f + '.info'
|
90
|
+
FileUtils.rm_rf f + '.files'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbbt-util'
|
4
|
+
require 'rbbt/util/simpleopt'
|
5
|
+
require 'rbbt/workflow'
|
6
|
+
require 'rbbt/monitor'
|
7
|
+
|
8
|
+
$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
|
9
|
+
|
10
|
+
options = SOPT.setup <<EOF
|
11
|
+
|
12
|
+
Report the status of the system
|
13
|
+
|
14
|
+
$ rbbt system status
|
15
|
+
|
16
|
+
-h--help Print this help
|
17
|
+
EOF
|
18
|
+
rbbt_usage and exit 0 if options[:help]
|
19
|
+
|
20
|
+
|
21
|
+
def pid_msg(pid)
|
22
|
+
color = if Misc.pid_exists? pid
|
23
|
+
:green
|
24
|
+
else
|
25
|
+
:red
|
26
|
+
end
|
27
|
+
Log.color(color, pid)
|
28
|
+
end
|
29
|
+
|
30
|
+
def status_msg(status)
|
31
|
+
color = case status
|
32
|
+
when :error, :aborted, :missing
|
33
|
+
:red
|
34
|
+
when :streaming, :started
|
35
|
+
:yellow
|
36
|
+
when :done
|
37
|
+
:green
|
38
|
+
else
|
39
|
+
if status.to_s.index ">"
|
40
|
+
:yellow
|
41
|
+
else
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
Log.color(color, status)
|
46
|
+
end
|
47
|
+
|
48
|
+
locks = Rbbt.locks
|
49
|
+
sensiblewrites = Rbbt.sensiblewrites
|
50
|
+
persists = Rbbt.persists
|
51
|
+
|
52
|
+
puts Log.color(:magenta, "# System report")
|
53
|
+
puts
|
54
|
+
if locks.any?
|
55
|
+
puts Log.color(:magenta, "Locks:")
|
56
|
+
locks.each do |lock|
|
57
|
+
pid, ppid, time = Rbbt.load_lock(lock)
|
58
|
+
time ||= File.atime lock
|
59
|
+
puts " " << lock + Log.color(:blue, " -- time: #{Time.now - time}; ppid: #{ppid}; pid: #{pid_msg pid}")
|
60
|
+
end
|
61
|
+
puts
|
62
|
+
end
|
63
|
+
|
64
|
+
if persists.any?
|
65
|
+
puts Log.color(:magenta, "Persist:")
|
66
|
+
persists.each do |persist|
|
67
|
+
puts " " << persist
|
68
|
+
end
|
69
|
+
puts
|
70
|
+
end
|
71
|
+
|
72
|
+
if sensiblewrites.any?
|
73
|
+
puts Log.color(:magenta, "Writing:")
|
74
|
+
sensiblewrites.each do |sensiblewrite|
|
75
|
+
pid, ppid, time = Rbbt.load_lock(sensiblewrite + '.lock')
|
76
|
+
puts " " << sensiblewrite + Log.color(:blue, " -- time: #{Time.now - time}; ppid: #{ppid}; pid: #{pid_msg pid}")
|
77
|
+
end
|
78
|
+
puts
|
79
|
+
end
|
80
|
+
|
81
|
+
jobs = Rbbt.jobs
|
82
|
+
|
83
|
+
puts Log.color(:magenta, "# Workflows:")
|
84
|
+
puts
|
85
|
+
jobs.each do |workflow, tasks|
|
86
|
+
tasks.each do |task, jobs|
|
87
|
+
puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:yellow, task) << ": "
|
88
|
+
done = []
|
89
|
+
other = {}
|
90
|
+
jobs.each do |file,h|
|
91
|
+
status = h[:status]
|
92
|
+
if h[:status] == :done
|
93
|
+
done << file
|
94
|
+
else
|
95
|
+
other[status||"missing"] ||= []
|
96
|
+
other[status||"missing"] << [file, h[:pid]]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
puts " " << Log.color(:green, "done") << ": " << done.length.to_s
|
100
|
+
other.each do |status, list|
|
101
|
+
puts " " << status_msg(status) << ": " << list.collect{|f,p| p.nil? ? f : f + " (#{pid_msg p})"} * ", "
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.13.
|
4
|
+
version: 5.13.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- lib/rbbt/entity.rb
|
131
131
|
- lib/rbbt/fix_width_table.rb
|
132
132
|
- lib/rbbt/knowledge_base.rb
|
133
|
+
- lib/rbbt/monitor.rb
|
133
134
|
- lib/rbbt/persist.rb
|
134
135
|
- lib/rbbt/persist/tsv.rb
|
135
136
|
- lib/rbbt/persist/tsv/cdb.rb
|
@@ -245,8 +246,10 @@ files:
|
|
245
246
|
- share/rbbt_commands/stat/density
|
246
247
|
- share/rbbt_commands/stat/log
|
247
248
|
- share/rbbt_commands/study/task
|
249
|
+
- share/rbbt_commands/system/clean
|
248
250
|
- share/rbbt_commands/system/purge
|
249
251
|
- share/rbbt_commands/system/report
|
252
|
+
- share/rbbt_commands/system/status
|
250
253
|
- share/rbbt_commands/tsv/attach
|
251
254
|
- share/rbbt_commands/tsv/change_id
|
252
255
|
- share/rbbt_commands/tsv/get
|