Class: OsCtl::Cli::Top::JsonExporter

Inherits:
View
  • Object
show all
Defined in:
lib/osctl/cli/top/json_exporter.rb

Defined Under Namespace

Classes: Wake

Instance Attribute Summary

Attributes inherited from View

#model, #rate

Instance Method Summary collapse

Methods inherited from View

#initialize

Constructor Details

This class inherits a constructor from OsCtl::Cli::Top::View

Instance Method Details

#startObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/osctl/cli/top/json_exporter.rb', line 8

def start
  Signal.trap('USR1') do
    raise Wake
  end

  loop do
    begin
      sleep(rate)

    rescue Wake
      # continue
    end

    model.measure
    puts model.data.to_json
    STDOUT.flush
  end
end