mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
Fixes in template & removed balancer stats for mongod servers
This commit is contained in:
@@ -33,7 +33,7 @@ const (
|
|||||||
DEFAULT_AUTHDB = "admin"
|
DEFAULT_AUTHDB = "admin"
|
||||||
DEFAULT_HOST = "localhost:27017"
|
DEFAULT_HOST = "localhost:27017"
|
||||||
DEFAULT_LOGLEVEL = "warn"
|
DEFAULT_LOGLEVEL = "warn"
|
||||||
DEFAULT_ORDERBY = "count" // comma separated list
|
DEFAULT_ORDERBY = "-count" // comma separated list
|
||||||
DEFAULT_SKIPCOLLECTIONS = "system.profile" // comma separated list
|
DEFAULT_SKIPCOLLECTIONS = "system.profile" // comma separated list
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -514,13 +514,14 @@ func getOptions() (*options, error) {
|
|||||||
|
|
||||||
getopt.IntVarLong(&opts.Limit, "limit", 'n', "Show the first n queries")
|
getopt.IntVarLong(&opts.Limit, "limit", 'n', "Show the first n queries")
|
||||||
|
|
||||||
getopt.ListVarLong(&opts.OrderBy, "order-by", 'o', "Comma separated list of order by fields (max values): "+
|
getopt.ListVarLong(&opts.OrderBy, "order-by", 'o',
|
||||||
|
"Comma separated list of order by fields (max values): "+
|
||||||
"count,ratio,query-time,docs-scanned,docs-returned. "+
|
"count,ratio,query-time,docs-scanned,docs-returned. "+
|
||||||
"- in front of the field name denotes reverse order.")
|
"- in front of the field name denotes reverse order. Default: "+DEFAULT_ORDERBY)
|
||||||
getopt.ListVarLong(&opts.SkipCollections, "skip-collections", 's', "A comma separated list of collections (namespaces) to skip."+
|
getopt.ListVarLong(&opts.SkipCollections, "skip-collections", 's', "A comma separated list of collections (namespaces) to skip."+
|
||||||
" Default: system.profile")
|
" Default: "+DEFAULT_SKIPCOLLECTIONS)
|
||||||
|
|
||||||
getopt.StringVarLong(&opts.AuthDB, "authenticationDatabase", 'a', "admin", "Databaase to use for optional MongoDB authentication. Default: admin")
|
getopt.StringVarLong(&opts.AuthDB, "authenticationDatabase", 'a', "admin", "Database to use for optional MongoDB authentication. Default: admin")
|
||||||
getopt.StringVarLong(&opts.Database, "database", 'd', "", "MongoDB database to profile")
|
getopt.StringVarLong(&opts.Database, "database", 'd', "", "MongoDB database to profile")
|
||||||
getopt.StringVarLong(&opts.LogLevel, "log-level", 'l', "Log level: error", "panic, fatal, error, warn, info, debug. Default: error")
|
getopt.StringVarLong(&opts.LogLevel, "log-level", 'l', "Log level: error", "panic, fatal, error, warn, info, debug. Default: error")
|
||||||
getopt.StringVarLong(&opts.Password, "password", 'p', "", "Password to use for optional MongoDB authentication").SetOptional()
|
getopt.StringVarLong(&opts.Password, "password", 'p', "", "Password to use for optional MongoDB authentication").SetOptional()
|
||||||
@@ -528,16 +529,21 @@ func getOptions() (*options, error) {
|
|||||||
|
|
||||||
getopt.SetParameters("host[:port]/database")
|
getopt.SetParameters("host[:port]/database")
|
||||||
|
|
||||||
getopt.Parse()
|
var gop = getopt.CommandLine
|
||||||
|
gop.Parse(os.Args)
|
||||||
|
if gop.NArgs() > 0 {
|
||||||
|
opts.Host = gop.Arg(0)
|
||||||
|
gop.Parse(gop.Args())
|
||||||
|
}
|
||||||
if opts.Help {
|
if opts.Help {
|
||||||
return opts, nil
|
return opts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
args := getopt.Args() // host is a positional arg
|
//args := getopt.Args() // host is a positional arg
|
||||||
if len(args) > 0 {
|
//if len(args) > 0 {
|
||||||
opts.Host = args[0]
|
// opts.Host = args[0]
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
if getopt.IsSet("order-by") {
|
if getopt.IsSet("order-by") {
|
||||||
validFields := []string{"count", "ratio", "query-time", "docs-scanned", "docs-returned"}
|
validFields := []string{"count", "ratio", "query-time", "docs-scanned", "docs-returned"}
|
||||||
|
@@ -207,6 +207,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
|
session.SetMode(mgo.Monotonic, true)
|
||||||
|
|
||||||
hostInfo, err := GetHostinfo(session)
|
hostInfo, err := GetHostinfo(session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -239,7 +240,7 @@ func main() {
|
|||||||
|
|
||||||
if hostInfo != nil {
|
if hostInfo != nil {
|
||||||
if security, err := GetSecuritySettings(session, hostInfo.Version); err != nil {
|
if security, err := GetSecuritySettings(session, hostInfo.Version); err != nil {
|
||||||
log.Printf("[Error] cannot get security settings: %v\n", err)
|
log.Errorf("[Error] cannot get security settings: %v\n", err)
|
||||||
} else {
|
} else {
|
||||||
t := template.Must(template.New("ssl").Parse(templates.Security))
|
t := template.Must(template.New("ssl").Parse(templates.Security))
|
||||||
t.Execute(os.Stdout, security)
|
t.Execute(os.Stdout, security)
|
||||||
@@ -270,12 +271,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hostInfo.NodeType == "mongos" {
|
||||||
if bs, err := GetBalancerStats(session); err != nil {
|
if bs, err := GetBalancerStats(session); err != nil {
|
||||||
log.Printf("[Error] cannot get balancer stats: %v\n", err)
|
log.Printf("[Error] cannot get balancer stats: %v\n", err)
|
||||||
} else {
|
} else {
|
||||||
t := template.Must(template.New("balancer").Parse(templates.BalancerStats))
|
t := template.Must(template.New("balancer").Parse(templates.BalancerStats))
|
||||||
t.Execute(os.Stdout, bs)
|
t.Execute(os.Stdout, bs)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,7 +466,7 @@ func GetSecuritySettings(session pmgo.SessionManager, ver string) (*security, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Users, err = session.DB("admin").C("system.users").Count()
|
s.Users, _ = session.DB("admin").C("system.users").Count()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "cannot get users count")
|
return nil, errors.Wrap(err, "cannot get users count")
|
||||||
}
|
}
|
||||||
@@ -799,7 +802,7 @@ func parseFlags() options {
|
|||||||
getopt.StringVarLong(&opts.User, "username", 'u', "", "Username to use for optional MongoDB authentication")
|
getopt.StringVarLong(&opts.User, "username", 'u', "", "Username to use for optional MongoDB authentication")
|
||||||
getopt.StringVarLong(&opts.Password, "password", 'p', "", "Password to use for optional MongoDB authentication").SetOptional()
|
getopt.StringVarLong(&opts.Password, "password", 'p', "", "Password to use for optional MongoDB authentication").SetOptional()
|
||||||
getopt.StringVarLong(&opts.AuthDB, "authenticationDatabase", 'a', "admin",
|
getopt.StringVarLong(&opts.AuthDB, "authenticationDatabase", 'a', "admin",
|
||||||
"Databaase to use for optional MongoDB authentication. Default: admin")
|
"Databaae to use for optional MongoDB authentication. Default: admin")
|
||||||
getopt.StringVarLong(&opts.LogLevel, "log-level", 'l', "error", "Log level: panic, fatal, error, warn, info, debug. Default: error")
|
getopt.StringVarLong(&opts.LogLevel, "log-level", 'l', "error", "Log level: panic, fatal, error, warn, info, debug. Default: error")
|
||||||
|
|
||||||
getopt.IntVarLong(&opts.RunningOpsSamples, "running-ops-samples", 's',
|
getopt.IntVarLong(&opts.RunningOpsSamples, "running-ops-samples", 's',
|
||||||
|
@@ -10,8 +10,10 @@ Unsharded Collections: {{.UnshardedColsCount}}
|
|||||||
Unsharded Data Size: {{.UnshardedDataSizeScaled}} {{.UnshardedDataSizeScale}}
|
Unsharded Data Size: {{.UnshardedDataSizeScaled}} {{.UnshardedDataSizeScale}}
|
||||||
{{- if .Chunks }}
|
{{- if .Chunks }}
|
||||||
### Chunks:
|
### Chunks:
|
||||||
{{ range .Chunks }}
|
{{- range .Chunks }}
|
||||||
{{- if .ID }} {{ printf "%5d" .Count }} : {{ printf "%-30s" .ID}}{{ end -}}
|
{{- if .ID }}
|
||||||
{{- end -}}
|
{{ printf "%5d" .Count }} : {{ printf "%-30s" .ID}}
|
||||||
{{ end -}}
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
`
|
`
|
||||||
|
Reference in New Issue
Block a user