diff --git a/cmd/admin-profile-start.go b/cmd/admin-profile-start.go index e0545e99..7f93d63f 100644 --- a/cmd/admin-profile-start.go +++ b/cmd/admin-profile-start.go @@ -21,6 +21,7 @@ import ( "github.com/minio/cli" "github.com/minio/mc/pkg/probe" + "github.com/minio/minio-go/v6/pkg/set" "github.com/minio/minio/pkg/console" "github.com/minio/minio/pkg/madmin" ) @@ -29,7 +30,7 @@ var adminProfileStartFlags = []cli.Flag{ cli.StringFlag{ Name: "type", Usage: "start profiler type, possible values are 'cpu', 'mem', 'block', 'mutex' and 'trace'", - Value: "mem", + Value: "cpu,mem,block", }, } @@ -50,9 +51,11 @@ FLAGS: {{range .VisibleFlags}}{{.}} {{end}} EXAMPLES: - 1. Start CPU profile + 1. Start CPU profiling only {{.Prompt}} {{.HelpName}} --type cpu myminio/ + 2. Start CPU, Memory and Block profiling concurrently + {{.Prompt}} {{.HelpName}} --type cpu,mem,block myminio/ `, } @@ -62,25 +65,31 @@ func checkAdminProfileStartSyntax(ctx *cli.Context) { cli.ShowCommandHelpAndExit(ctx, "start", 1) // last argument is exit code } - profilerTypes := []madmin.ProfilerType{ + s := set.NewStringSet() + supportedProfilerTypes := []madmin.ProfilerType{ madmin.ProfilerCPU, madmin.ProfilerMEM, madmin.ProfilerBlock, madmin.ProfilerMutex, madmin.ProfilerTrace, } - + for _, profilerType := range supportedProfilerTypes { + s.Add(string(profilerType)) + } // Check if the provided profiler type is known and supported supportedProfiler := false - profilerType := strings.ToLower(ctx.String("type")) - for _, profiler := range profilerTypes { - if profilerType == string(profiler) { - supportedProfiler = true - break + profilers := strings.Split(strings.ToLower(ctx.String("type")), ",") + for _, profiler := range profilers { + if profiler != "" { + if s.Contains(profiler) { + supportedProfiler = true + break + } } } if !supportedProfiler { - fatalIf(errDummy(), "Profiler type unrecognized. Possible values are: %v.", profilerTypes) + fatalIf(errDummy().Trace(ctx.String("type")), + "Profiler type unrecognized. Possible values are: %v.", supportedProfilerTypes) } } @@ -93,7 +102,7 @@ func mainAdminProfileStart(ctx *cli.Context) error { args := ctx.Args() aliasedURL := args.Get(0) - profilerType := ctx.String("type") + profilers := ctx.String("type") // Create a new MinIO Admin Client client, err := newAdminClient(aliasedURL) @@ -103,7 +112,7 @@ func mainAdminProfileStart(ctx *cli.Context) error { } // Start profile - _, cmdErr := client.StartProfiling(madmin.ProfilerType(profilerType)) + _, cmdErr := client.StartProfiling(madmin.ProfilerType(profilers)) fatalIf(probe.NewError(cmdErr), "Unable to start profile.") console.Infoln("Profile data successfully started.") diff --git a/cmd/admin-profile.go b/cmd/admin-profile.go index 7a1e3ba6..79373ffb 100644 --- a/cmd/admin-profile.go +++ b/cmd/admin-profile.go @@ -1,5 +1,5 @@ /* - * MinIO Client (C) 2018 MinIO, Inc. + * MinIO Client (C) 2018-2020 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/go.mod b/go.mod index ee34398a..225dc307 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/mattn/go-isatty v0.0.7 github.com/mattn/go-runewidth v0.0.5 // indirect github.com/minio/cli v1.22.0 - github.com/minio/minio v0.0.0-20191231040613-0b7bd024fb30 + github.com/minio/minio v0.0.0-20200116031140-080e0c2323c7 github.com/minio/minio-go/v6 v6.0.45-0.20200111053019-ae2a6fd9071d github.com/minio/sha256-simd v0.1.1 github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index cedb9863..fd56e134 100644 --- a/go.sum +++ b/go.sum @@ -207,8 +207,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.9.4 h1:xhvAeUPQ2drNUhKtrGdTGNvV9nNafHMUkRyLkzxJoB4= github.com/klauspost/compress v1.9.4/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/cpuid v1.2.2/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM= github.com/klauspost/pgzip v1.2.1/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/readahead v1.3.1 h1:QqXNYvm+VvqYcbrRT4LojUciM0XrznFRIDrbHiJtu/0= @@ -258,8 +258,8 @@ github.com/minio/highwayhash v1.0.0 h1:iMSDhgUILCr0TNm8LWlSjF8N0ZIj2qbO8WHp6Q/J2 github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc= github.com/minio/lsync v1.0.1 h1:AVvILxA976xc27hstd1oR+X9PQG0sPSom1MNb1ImfUs= github.com/minio/lsync v1.0.1/go.mod h1:tCFzfo0dlvdGl70IT4IAK/5Wtgb0/BrTmo/jE8pArKA= -github.com/minio/minio v0.0.0-20191231040613-0b7bd024fb30 h1:s6Bt9fdUAbQ1UFssnNgB79o6xTrTHVEk3Q96QF3qAw8= -github.com/minio/minio v0.0.0-20191231040613-0b7bd024fb30/go.mod h1:4Aa1o4tNqOR8ZAR80H2UCTcIi7w6H1QqHywiKXcYimM= +github.com/minio/minio v0.0.0-20200116031140-080e0c2323c7 h1:WV81PWc8Eo5Jc1SeawytwBXaiXQAkVXgp+K9M0Daji8= +github.com/minio/minio v0.0.0-20200116031140-080e0c2323c7/go.mod h1:HH1U0HOUzfjsCGlGCncWDh8L3zPejMhMDDsLAETqXs0= github.com/minio/minio-go/v6 v6.0.44/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg= github.com/minio/minio-go/v6 v6.0.45-0.20200111053019-ae2a6fd9071d h1:7EchHJZmXIsvxCrko5PcoipB6XQb/LMH+Xzpz0s5wwA= github.com/minio/minio-go/v6 v6.0.45-0.20200111053019-ae2a6fd9071d/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=