Class: Norikra::Client::Admin

Inherits:
Thor
  • Object
show all
Includes:
CLIUtil
Defined in:
lib/norikra/client/cli.rb

Instance Method Summary collapse

Methods included from CLIUtil

#client, #formatter, #parser, #wrap

Instance Method Details

#statsObject



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/norikra/client/cli.rb', line 220

def stats
  client = client(parent_options)

  targets = []
  queries = []

  wrap do
    queries = client.queries()

    client.targets().each do |t|
      fields = {}
      client.fields(t['name']).each do |f|
        next if f['type'] == 'hash' || f['type'] == 'array'
        fields[f['name']] = f
      end
      targets.push( { "name" => t['name'], "fields" => fields, "auto_field" => t['auto_field'] } )
    end
  end

  require 'json'

  puts JSON.pretty_generate({
      "threads" => {
        "engine" => { "inbound" => {}, "outbound" => {}, "route_exec" => {}, "timer_exec" => {} },
        "rpc" => {},
        "web" => {},
      },
      "log" => {},
      "targets" => targets,
      "queries" => queries,
    })
end