PT-57 improved help for pt-mongodb-query-digest

This commit is contained in:
Carlos Salguero
2017-01-24 17:40:09 -03:00
parent b2406d8da4
commit 80c7d042ab

View File

@@ -157,7 +157,7 @@ func main() {
di := getDialInfo(opts)
if di.Database == "" {
log.Printf("must indicate a database")
log.Errorln("must indicate a database as host:[port]/database")
getopt.PrintUsage(os.Stderr)
os.Exit(2)
}
@@ -168,6 +168,17 @@ func main() {
os.Exit(3)
}
var ps proto.ProfilerStatus
if err := session.DB(di.Database).Run(bson.M{"profile": -1}, &ps); err != nil {
log.Errorf("Cannot get profiler status: %s", err.Error())
os.Exit(2)
}
if ps.Was == 0 {
log.Errorf("Profiler is not enabled for the %s database", di.Database)
os.Exit(3)
}
i := session.DB(di.Database).C("system.profile").Find(bson.M{"op": bson.M{"$nin": []string{"getmore", "delete"}}}).Sort("-$natural").Iter()
queries := sortQueries(getData(i), opts.OrderBy)
@@ -424,7 +435,7 @@ func getOptions() (*options, error) {
getopt.StringVarLong(&opts.Password, "password", 'p', "", "password").SetOptional()
getopt.StringVarLong(&opts.User, "user", 'u', "username")
getopt.SetParameters("host[:port][/database]")
getopt.SetParameters("host[:port]/database")
getopt.Parse()
if opts.Help {
@@ -434,6 +445,7 @@ func getOptions() (*options, error) {
args := getopt.Args() // host is a positional arg
if len(args) > 0 {
opts.Host = args[0]
}
if getopt.IsSet("order-by") {