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



270
271
272
273
274
275
276
277
278
# File 'lib/norikra/client/cli.rb', line 270

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



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/norikra/client/cli.rb', line 235

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