Class: ProbeListener
- Inherits:
-
Object
- Object
- ProbeListener
- Defined in:
- lib/dtracer/probe_listener.rb
Instance Method Summary collapse
-
#initialize(name, is_hash) ⇒ ProbeListener
constructor
A new instance of ProbeListener.
- #listen ⇒ Object
Constructor Details
#initialize(name, is_hash) ⇒ ProbeListener
Returns a new instance of ProbeListener.
5 6 7 8 9 |
# File 'lib/dtracer/probe_listener.rb', line 5 def initialize(name, is_hash) @name = name @probe_string = probe_string(name) @is_hash = is_hash end |
Instance Method Details
#listen ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dtracer/probe_listener.rb', line 11 def listen write_probe cmd = "sudo dtrace -s #{trace_file_path}" IO.popen(cmd) do |stdout| stdout.each do |line| if @is_hash value = try_parse(line) next unless value else value = line.strip next if value.empty? end puts "\n#{@name.capitalize}----------------------------------------------" yield(value) end end clean_up end |