mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-20 10:55:01 +00:00
PT-182 Fixed merging conflicts
This commit is contained in:
@@ -71,7 +71,7 @@ func main() {
|
|||||||
|
|
||||||
opts, err := getOptions()
|
opts, err := getOptions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("error processing commad line arguments: %s", err)
|
log.Errorf("error processing command line arguments: %s", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if opts == nil && err == nil {
|
if opts == nil && err == nil {
|
||||||
@@ -104,6 +104,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("Command line options:\n%+v\n", opts)
|
||||||
|
|
||||||
di := getDialInfo(opts)
|
di := getDialInfo(opts)
|
||||||
if di.Database == "" {
|
if di.Database == "" {
|
||||||
log.Errorln("must indicate a database as host:[port]/database")
|
log.Errorln("must indicate a database as host:[port]/database")
|
||||||
@@ -113,6 +115,7 @@ func main() {
|
|||||||
|
|
||||||
dialer := pmgo.NewDialer()
|
dialer := pmgo.NewDialer()
|
||||||
session, err := dialer.DialWithInfo(di)
|
session, err := dialer.DialWithInfo(di)
|
||||||
|
log.Debugf("Dial Info: %+v\n", di)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error connecting to the db: %s while trying to connect to %s", err, di.Addrs[0])
|
log.Errorf("Error connecting to the db: %s while trying to connect to %s", err, di.Addrs[0])
|
||||||
os.Exit(3)
|
os.Exit(3)
|
||||||
@@ -142,8 +145,7 @@ func main() {
|
|||||||
filters = append(filters, filter.NewFilterByCollection(opts.SkipCollections))
|
filters = append(filters, filter.NewFilterByCollection(opts.SkipCollections))
|
||||||
}
|
}
|
||||||
|
|
||||||
query := bson.M{"op": bson.M{"$nin": []string{"getmore", "delete"}}}
|
i := session.DB(di.Database).C("system.profile").Find(bson.M{}).Sort("-$natural").Iter()
|
||||||
i := session.DB(di.Database).C("system.profile").Find(query).Sort("-$natural").Iter()
|
|
||||||
|
|
||||||
fp := fingerprinter.NewFingerprinter(fingerprinter.DEFAULT_KEY_FILTERS)
|
fp := fingerprinter.NewFingerprinter(fingerprinter.DEFAULT_KEY_FILTERS)
|
||||||
s := stats.New(fp)
|
s := stats.New(fp)
|
||||||
@@ -160,6 +162,10 @@ func main() {
|
|||||||
sortedQueryStats = sortedQueryStats[:opts.Limit]
|
sortedQueryStats = sortedQueryStats[:opts.Limit]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(queries) == 0 {
|
||||||
|
log.Errorf("No queries found in profiler information for database %q\n", di.Database)
|
||||||
|
return
|
||||||
|
}
|
||||||
rep := report{
|
rep := report{
|
||||||
Headers: getHeaders(opts),
|
Headers: getHeaders(opts),
|
||||||
QueryTotals: queries.CalcTotalQueriesStats(uptime),
|
QueryTotals: queries.CalcTotalQueriesStats(uptime),
|
||||||
@@ -322,10 +328,10 @@ func getDialInfo(opts *options) *pmgo.DialInfo {
|
|||||||
di, _ := mgo.ParseURL(opts.Host)
|
di, _ := mgo.ParseURL(opts.Host)
|
||||||
di.FailFast = true
|
di.FailFast = true
|
||||||
|
|
||||||
if di.Username != "" {
|
if di.Username == "" {
|
||||||
di.Username = opts.User
|
di.Username = opts.User
|
||||||
}
|
}
|
||||||
if di.Password != "" {
|
if di.Password == "" {
|
||||||
di.Password = opts.Password
|
di.Password = opts.Password
|
||||||
}
|
}
|
||||||
if opts.AuthDB != "" {
|
if opts.AuthDB != "" {
|
||||||
@@ -369,9 +375,9 @@ func getQueryTemplate() string {
|
|||||||
# Exec Time ms {{printf "% 4.0f" .QueryTime.Pct}} {{printf "% 7.0f " .QueryTime.Total}} {{printf "% 7.0f " .QueryTime.Min}} {{printf "% 7.0f " .QueryTime.Max}} {{printf "% 7.0f " .QueryTime.Avg}} {{printf "% 7.0f " .QueryTime.Pct95}} {{printf "% 7.0f " .QueryTime.StdDev}} {{printf "% 7.0f " .QueryTime.Median}}
|
# Exec Time ms {{printf "% 4.0f" .QueryTime.Pct}} {{printf "% 7.0f " .QueryTime.Total}} {{printf "% 7.0f " .QueryTime.Min}} {{printf "% 7.0f " .QueryTime.Max}} {{printf "% 7.0f " .QueryTime.Avg}} {{printf "% 7.0f " .QueryTime.Pct95}} {{printf "% 7.0f " .QueryTime.StdDev}} {{printf "% 7.0f " .QueryTime.Median}}
|
||||||
# Docs Scanned {{printf "% 4.0f" .Scanned.Pct}} {{Format .Scanned.Total 7.2}} {{Format .Scanned.Min 7.2}} {{Format .Scanned.Max 7.2}} {{Format .Scanned.Avg 7.2}} {{Format .Scanned.Pct95 7.2}} {{Format .Scanned.StdDev 7.2}} {{Format .Scanned.Median 7.2}}
|
# Docs Scanned {{printf "% 4.0f" .Scanned.Pct}} {{Format .Scanned.Total 7.2}} {{Format .Scanned.Min 7.2}} {{Format .Scanned.Max 7.2}} {{Format .Scanned.Avg 7.2}} {{Format .Scanned.Pct95 7.2}} {{Format .Scanned.StdDev 7.2}} {{Format .Scanned.Median 7.2}}
|
||||||
# Docs Returned {{printf "% 4.0f" .Returned.Pct}} {{Format .Returned.Total 7.2}} {{Format .Returned.Min 7.2}} {{Format .Returned.Max 7.2}} {{Format .Returned.Avg 7.2}} {{Format .Returned.Pct95 7.2}} {{Format .Returned.StdDev 7.2}} {{Format .Returned.Median 7.2}}
|
# Docs Returned {{printf "% 4.0f" .Returned.Pct}} {{Format .Returned.Total 7.2}} {{Format .Returned.Min 7.2}} {{Format .Returned.Max 7.2}} {{Format .Returned.Avg 7.2}} {{Format .Returned.Pct95 7.2}} {{Format .Returned.StdDev 7.2}} {{Format .Returned.Median 7.2}}
|
||||||
# Bytes recv {{printf "% 4.0f" .ResponseLength.Pct}} {{Format .ResponseLength.Total 7.2}} {{Format .ResponseLength.Min 7.2}} {{Format .ResponseLength.Max 7.2}} {{Format .ResponseLength.Avg 7.2}} {{Format .ResponseLength.Pct95 7.2}} {{Format .ResponseLength.StdDev 7.2}} {{Format .ResponseLength.Median 7.2}}
|
# Bytes sent {{printf "% 4.0f" .ResponseLength.Pct}} {{Format .ResponseLength.Total 7.2}} {{Format .ResponseLength.Min 7.2}} {{Format .ResponseLength.Max 7.2}} {{Format .ResponseLength.Avg 7.2}} {{Format .ResponseLength.Pct95 7.2}} {{Format .ResponseLength.StdDev 7.2}} {{Format .ResponseLength.Median 7.2}}
|
||||||
# String:
|
# String:
|
||||||
# Namespaces {{.Namespace}}
|
# Namespace {{.Namespace}}
|
||||||
# Operation {{.Operation}}
|
# Operation {{.Operation}}
|
||||||
# Fingerprint {{.Fingerprint}}
|
# Fingerprint {{.Fingerprint}}
|
||||||
# Query {{.Query}}
|
# Query {{.Query}}
|
||||||
@@ -389,7 +395,7 @@ func getTotalsTemplate() string {
|
|||||||
# Exec Time ms {{printf "% 4.0f" .QueryTime.Pct}} {{printf "% 7.0f " .QueryTime.Total}} {{printf "% 7.0f " .QueryTime.Min}} {{printf "% 7.0f " .QueryTime.Max}} {{printf "% 7.0f " .QueryTime.Avg}} {{printf "% 7.0f " .QueryTime.Pct95}} {{printf "% 7.0f " .QueryTime.StdDev}} {{printf "% 7.0f " .QueryTime.Median}}
|
# Exec Time ms {{printf "% 4.0f" .QueryTime.Pct}} {{printf "% 7.0f " .QueryTime.Total}} {{printf "% 7.0f " .QueryTime.Min}} {{printf "% 7.0f " .QueryTime.Max}} {{printf "% 7.0f " .QueryTime.Avg}} {{printf "% 7.0f " .QueryTime.Pct95}} {{printf "% 7.0f " .QueryTime.StdDev}} {{printf "% 7.0f " .QueryTime.Median}}
|
||||||
# Docs Scanned {{printf "% 4.0f" .Scanned.Pct}} {{Format .Scanned.Total 7.2}} {{Format .Scanned.Min 7.2}} {{Format .Scanned.Max 7.2}} {{Format .Scanned.Avg 7.2}} {{Format .Scanned.Pct95 7.2}} {{Format .Scanned.StdDev 7.2}} {{Format .Scanned.Median 7.2}}
|
# Docs Scanned {{printf "% 4.0f" .Scanned.Pct}} {{Format .Scanned.Total 7.2}} {{Format .Scanned.Min 7.2}} {{Format .Scanned.Max 7.2}} {{Format .Scanned.Avg 7.2}} {{Format .Scanned.Pct95 7.2}} {{Format .Scanned.StdDev 7.2}} {{Format .Scanned.Median 7.2}}
|
||||||
# Docs Returned {{printf "% 4.0f" .Returned.Pct}} {{Format .Returned.Total 7.2}} {{Format .Returned.Min 7.2}} {{Format .Returned.Max 7.2}} {{Format .Returned.Avg 7.2}} {{Format .Returned.Pct95 7.2}} {{Format .Returned.StdDev 7.2}} {{Format .Returned.Median 7.2}}
|
# Docs Returned {{printf "% 4.0f" .Returned.Pct}} {{Format .Returned.Total 7.2}} {{Format .Returned.Min 7.2}} {{Format .Returned.Max 7.2}} {{Format .Returned.Avg 7.2}} {{Format .Returned.Pct95 7.2}} {{Format .Returned.StdDev 7.2}} {{Format .Returned.Median 7.2}}
|
||||||
# Bytes recv {{printf "% 4.0f" .ResponseLength.Pct}} {{Format .ResponseLength.Total 7.2}} {{Format .ResponseLength.Min 7.2}} {{Format .ResponseLength.Max 7.2}} {{Format .ResponseLength.Avg 7.2}} {{Format .ResponseLength.Pct95 7.2}} {{Format .ResponseLength.StdDev 7.2}} {{Format .ResponseLength.Median 7.2}}
|
# Bytes sent {{printf "% 4.0f" .ResponseLength.Pct}} {{Format .ResponseLength.Total 7.2}} {{Format .ResponseLength.Min 7.2}} {{Format .ResponseLength.Max 7.2}} {{Format .ResponseLength.Avg 7.2}} {{Format .ResponseLength.Pct95 7.2}} {{Format .ResponseLength.StdDev 7.2}} {{Format .ResponseLength.Median 7.2}}
|
||||||
#
|
#
|
||||||
`
|
`
|
||||||
return t
|
return t
|
||||||
@@ -469,15 +475,11 @@ func sortQueries(queries []stats.QueryStats, orderby []string) []stats.QueryStat
|
|||||||
|
|
||||||
case "ratio":
|
case "ratio":
|
||||||
f = func(c1, c2 *stats.QueryStats) bool {
|
f = func(c1, c2 *stats.QueryStats) bool {
|
||||||
ratio1 := c1.Scanned.Max / c1.Returned.Max
|
return c1.Ratio < c2.Ratio
|
||||||
ratio2 := c2.Scanned.Max / c2.Returned.Max
|
|
||||||
return ratio1 < ratio2
|
|
||||||
}
|
}
|
||||||
case "-ratio":
|
case "-ratio":
|
||||||
f = func(c1, c2 *stats.QueryStats) bool {
|
f = func(c1, c2 *stats.QueryStats) bool {
|
||||||
ratio1 := c1.Scanned.Max / c1.Returned.Max
|
return c1.Ratio > c2.Ratio
|
||||||
ratio2 := c2.Scanned.Max / c2.Returned.Max
|
|
||||||
return ratio1 > ratio2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -529,6 +531,7 @@ func isProfilerEnabled(dialer pmgo.Dialer, di *pmgo.DialInfo) (bool, error) {
|
|||||||
for _, member := range replicaMembers {
|
for _, member := range replicaMembers {
|
||||||
// Stand alone instances return state = REPLICA_SET_MEMBER_STARTUP
|
// Stand alone instances return state = REPLICA_SET_MEMBER_STARTUP
|
||||||
di.Addrs = []string{member.Name}
|
di.Addrs = []string{member.Name}
|
||||||
|
di.Direct = true
|
||||||
session, err := dialer.DialWithInfo(di)
|
session, err := dialer.DialWithInfo(di)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user