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

#logsObject



308
309
310
311
312
313
314
315
316
# File 'lib/norikra/client/cli.rb', line 308

def logs
  opt = parent_options
  client = client(parent_options)
  wrap do
    client.logs().each do |time, level, line|
      puts "#{time} [#{level}] #{line}"
    end
  end
end

#statsObject



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/norikra/client/cli.rb', line 273

def stats
  opt = parent_options
  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