Module: ProcPath
- Defined in:
- lib/rbbt/util/procpath.rb
Class Method Summary collapse
- .monitor(pid, path) ⇒ Object
- .plot(path, output, options = {}) ⇒ Object
- .record(pid, path, options = {}) ⇒ Object
Class Method Details
.monitor(pid, path) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rbbt/util/procpath.rb', line 37 def self.monitor(pid, path) database, = path.split("#") = .nil? ? {} : Misc.string2hash() database = File. database Log.low "ProcPath monitor #{pid} in #{database} (#{Misc.fingerprint })" ProcPath.record(pid, database + '.sqlite3', ) ProcPath.plot(database + '.sqlite3', database + '.cpu.svg', .merge("query-name" => 'cpu')) ProcPath.plot(database + '.sqlite3', database + '.rss.svg', .merge("query-name" => 'rss')) end |
.plot(path, output, options = {}) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/rbbt/util/procpath.rb', line 29 def self.plot(path, output, = {}) IndiferentHash.setup() = Misc.add_defaults , "query-name" => 'rss', 'epsilon' => 0.5, "moving-average-window" => 10 = %w(query-name epsilon monitor-average-window title logarithmic after before custom-query-file custom-value-expr).inject({}){|acc,k| acc[k] = [k]; acc} CMD.cmd_log(:procpath, "plot --database-file '#{path}' --plot-file '#{output}' ", .merge(:nofail => true, :add_option_dashes => true)) end |
.record(pid, path, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rbbt/util/procpath.rb', line 7 def self.record(pid, path, = {}) IndiferentHash.setup() = Misc.add_defaults , "interval" => 30 = %w(interval recnum reevalnum).inject({}){|acc,k| acc[k] = [k]; acc} Log.debug "ProcPath recording #{pid} in #{path} (#{Misc.fingerprint })" procpath_thread = Thread.new do begin procpath_pid = CMD.cmd_pid(:procpath, "record --database-file '#{path}' '$..children[?(@.stat.pid == #{pid})]'", .merge(:nofail => true, :add_option_dashes => true)) rescue Exception Log.exceptions $! Process.kill "INT", procpath_pid end end procpath_thread.report_on_exception = false Process.wait pid.to_i procpath_thread.raise Interrupt end |