MCPcopy Create free account
hub / github.com/distributedio/titan / Info

Function Info

command/server.go:361–396  ·  view source on GitHub ↗

Info returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans

(ctx *Context)

Source from the content-addressed store, hash-verified

359
360// Info returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans
361func Info(ctx *Context) {
362 exe, err := os.Executable()
363 if err != nil {
364 resp.ReplyError(ctx.Out, "ERR "+err.Error())
365 }
366
367 // count the number of clients
368 var numberOfClients int
369 ctx.Server.Clients.Range(func(k, v interface{}) bool {
370 numberOfClients++
371 return true
372 })
373
374 var lines []string
375 lines = append(lines, "# Server")
376 lines = append(lines, "titan_version:"+context.ReleaseVersion)
377 lines = append(lines, "titan_git_sha1:"+context.GitHash)
378 lines = append(lines, "titan_build_id:"+context.BuildTS)
379 lines = append(lines, "os:"+runtime.GOOS)
380 lines = append(lines, "arch_bits:"+runtime.GOARCH)
381 lines = append(lines, "go_version:"+context.GolangVersion)
382 lines = append(lines, "process_id:"+strconv.Itoa(os.Getpid()))
383 lines = append(lines, "uptime_in_seconds:"+strconv.FormatInt(int64(time.Since(ctx.Server.StartAt)/time.Second), 10))
384 lines = append(lines, "uptime_in_days:"+strconv.FormatInt(int64(time.Since(ctx.Server.StartAt)/time.Second/86400), 10))
385 lines = append(lines, "executable:"+exe)
386
387 lines = append(lines, "# Clients")
388 lines = append(lines, "connected_clients:"+strconv.Itoa(numberOfClients))
389 lines = append(lines, "client_longest_output_list:0")
390 lines = append(lines, "client_biggest_input_buf:0")
391 lines = append(lines, "blocked_clients:0")
392 lines = append(lines, "client_namespace:"+ctx.Client.Namespace)
393
394 resp.ReplyBulkString(ctx.Out, strings.Join(lines, "\n")+"\n")
395 return
396}

Callers 1

TestInfoFunction · 0.85

Calls 4

ReplyErrorFunction · 0.92
ReplyBulkStringFunction · 0.92
ErrorMethod · 0.65
RangeMethod · 0.65

Tested by 1

TestInfoFunction · 0.68