diff --git a/bin/pt-kill b/bin/pt-kill index 604e906b..ee7a9149 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -8731,7 +8731,7 @@ type: string; default: Query group: Actions -Comma sepatated list of commands that will be watched/killed if they ran for +Comma separated list of commands that will be watched/killed if they ran for more than L<"--busy-time"> seconds. Default: C By default, L<"--busy-time"> kills only C commands but in some cases, it diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 4c3b2dfa..5030e7e9 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -11668,7 +11668,7 @@ sub check_orig_table { Cxn => $cxn, tbl => $orig_tbl, chunk_size => $o->get('chunk-size'), - chunk_indx => $o->get('chunk-index'), + chunk_index => $o->get('chunk-index'), OptionParser => $o, TableParser => $tp, ); @@ -13512,7 +13512,7 @@ New rows will use the user defined default value if specified for the column. =item --only-same-schema-fks Check foreigns keys only on tables on the same schema than the original table. -This option is dangerous since if you have FKs refenrencing tables in other +This option is dangerous since if you have FKs referencing tables in other schemas, they won't be detected. diff --git a/bin/pt-query-digest b/bin/pt-query-digest index bf51c82b..693f5430 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -6239,7 +6239,7 @@ sub _get_value { unless $found_value; } else { - die "Event does not have attribute $attrib and there are no alterantes"; + die "Event does not have attribute $attrib and there are no alternates"; } return $value; diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 7493e347..4c167225 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -12591,7 +12591,7 @@ sub create_repl_table { # # Required Arguments: # * tbl - Standard tbl hashref -# * sth - Sth with EXLAIN +# * sth - Sth with EXPLAIN # * vals - Values for sth, if any # # Returns: diff --git a/bin/pt-variable-advisor b/bin/pt-variable-advisor index ee0152cf..571ed114 100755 --- a/bin/pt-variable-advisor +++ b/bin/pt-variable-advisor @@ -6082,7 +6082,7 @@ as tmp_table_size. severity: warn These are the recommended minimum version for each major release: 3.23, 4.1.20, -5.0.37, 5.1.30, 5.5.8, 5.6.10, 5.7.9, 8.0.11. This optiion does not complain +5.0.37, 5.1.30, 5.5.8, 5.6.10, 5.7.9, 8.0.11. This option does not complain about Innovation releases. =item end-of-life mysql version diff --git a/lib/Diskstats.pm b/lib/Diskstats.pm index f62cc6fd..8102aa5e 100644 --- a/lib/Diskstats.pm +++ b/lib/Diskstats.pm @@ -20,7 +20,7 @@ { # Package: Diskstats # This package implements most of the logic in the old shell pt-diskstats; -# it parses data from /proc/diskstats, calculcates deltas, and prints those. +# it parses data from /proc/diskstats, calculates deltas, and prints those. package Diskstats; diff --git a/lib/EventAggregator.pm b/lib/EventAggregator.pm index 40f7ca58..217dd436 100644 --- a/lib/EventAggregator.pm +++ b/lib/EventAggregator.pm @@ -1193,7 +1193,7 @@ sub _get_value { unless $found_value; } else { - die "Event does not have attribute $attrib and there are no alterantes"; + die "Event does not have attribute $attrib and there are no alternates"; } return $value; diff --git a/lib/SQLParser.pm b/lib/SQLParser.pm index 514a30d7..ba7d09ea 100644 --- a/lib/SQLParser.pm +++ b/lib/SQLParser.pm @@ -1254,7 +1254,7 @@ sub remove_functions { # GROUP BY and ORDER BY specify a list of identifiers. # # Parameters: -# $idents - Arrayref of indentifiers +# $idents - Arrayref of identifiers # # Returns: # Arrayref of hashes with each identifier's parts, depending on what kind diff --git a/lib/SimpleTCPDumpParser.pm b/lib/SimpleTCPDumpParser.pm index b462b9a5..d34642f7 100644 --- a/lib/SimpleTCPDumpParser.pm +++ b/lib/SimpleTCPDumpParser.pm @@ -79,8 +79,8 @@ sub new { # # TCP requests and responses form "sessions", which can be in one of these # statuses: -# [Q]uerying - The remote host is sending the query to the server. -# [R]esponding - The server is replying back to the remote host. +# Querying - The remote host is sending the query to the server. +# Responding - The server is replying back to the remote host. sub parse_event { my ( $self, %args ) = @_; my @required_args = qw(next_event tell); diff --git a/lib/TCPRequestAggregator.pm b/lib/TCPRequestAggregator.pm index b5c49642..27ea5705 100644 --- a/lib/TCPRequestAggregator.pm +++ b/lib/TCPRequestAggregator.pm @@ -178,7 +178,7 @@ sub parse_event { # Otherwise, we need to compute the running sums and keep looping. else { if ( $self->{in_prg} ) { - # $self->{current_ts} is intitially 0, which would seem likely to + # $self->{current_ts} is initially 0, which would seem likely to # skew this computation. But $self->{in_prg} will be 0 also, and # $self->{current_ts} will get set immediately after this, so # anytime this if() block runs, it'll be OK. diff --git a/lib/VersionCheck.pm b/lib/VersionCheck.pm index 13bda834..d8b7ded7 100644 --- a/lib/VersionCheck.pm +++ b/lib/VersionCheck.pm @@ -460,7 +460,7 @@ sub pingback { # If the server has suggestions for items, it sends them back in # the same format: ITEM:TYPE:SUGGESTION\n. ITEM:TYPE is mostly for - # debugging; the tool just repports the suggestions. + # debugging; the tool just reports the suggestions. $items = parse_server_response( response => $response->{content}, split_vars => 0, diff --git a/src/go/pt-mongodb-summary/main.go b/src/go/pt-mongodb-summary/main.go index 3dce453c..90c2c9f4 100644 --- a/src/go/pt-mongodb-summary/main.go +++ b/src/go/pt-mongodb-summary/main.go @@ -208,7 +208,7 @@ func main() { if err != nil { log.Infof("cannot check version updates: %s", err.Error()) } else if advice != "" { - log.Infof(advice) + log.Infof("%s", advice) } } @@ -373,24 +373,6 @@ func getHostInfo(ctx context.Context, client *mongo.Client) (*hostInfo, error) { return nil, errors.Wrap(err, "GetHostInfo.hostInfo") } - cmdOpts := proto.CommandLineOptions{} - query := primitive.D{{Key: "getCmdLineOpts", Value: 1}} - err := client.Database("admin").RunCommand(ctx, query).Decode(&cmdOpts) - if err != nil { - return nil, errors.Wrap(err, "cannot get command line options") - } - - ss := proto.ServerStatus{} - query = primitive.D{{Key: "serverStatus", Value: 1}} - if err := client.Database("admin").RunCommand(ctx, query).Decode(&ss); err != nil { - return nil, errors.Wrap(err, "GetHostInfo.serverStatus") - } - - pi := procInfo{} - if err := getProcInfo(int32(ss.Pid), &pi); err != nil { - pi.Error = err - } - nodeType, _ := getNodeType(ctx, client) procCount, _ := countMongodProcesses() @@ -398,24 +380,41 @@ func getHostInfo(ctx context.Context, client *mongo.Client) (*hostInfo, error) { Hostname: hi.System.Hostname, HostOsType: hi.Os.Type, HostSystemCPUArch: hi.System.CpuArch, - DBPath: "", // Sets default. It will be overridden later if necessary - - ProcessName: ss.Process, - ProcProcessCount: procCount, - Version: ss.Version, - NodeType: nodeType, - - ProcPath: pi.Path, - ProcUserName: pi.UserName, - ProcCreateTime: pi.CreateTime, - CmdlineArgs: cmdOpts.Argv, - } - if ss.Repl != nil { - i.ReplicasetName = ss.Repl.SetName + ProcProcessCount: procCount, + NodeType: nodeType, + CmdlineArgs: nil, } - if cmdOpts.Parsed.Storage.DbPath != "" { - i.DBPath = cmdOpts.Parsed.Storage.DbPath + var cmdOpts proto.CommandLineOptions + query := primitive.D{{Key: "getCmdLineOpts", Value: 1}} + err := client.Database("admin").RunCommand(ctx, query).Decode(&cmdOpts) + if err == nil { + if len(cmdOpts.Argv) > 0 { + i.CmdlineArgs = cmdOpts.Argv + } + if cmdOpts.Parsed.Storage.DbPath != "" { + i.DBPath = cmdOpts.Parsed.Storage.DbPath + } + } + + var ss proto.ServerStatus + query = primitive.D{{Key: "serverStatus", Value: 1}} + err = client.Database("admin").RunCommand(ctx, query).Decode(&ss) + if err == nil { + i.ProcessName = ss.Process + i.Version = ss.Version + if ss.Repl != nil { + i.ReplicasetName = ss.Repl.SetName + } + + pi := procInfo{} + if err := getProcInfo(int32(ss.Pid), &pi); err != nil { + pi.Error = err + } else { + i.ProcPath = pi.Path + i.ProcUserName = pi.UserName + i.ProcCreateTime = pi.CreateTime + } } return i, nil diff --git a/src/go/pt-mongodb-summary/main_test.go b/src/go/pt-mongodb-summary/main_test.go index 57f7196d..3abbf0d5 100644 --- a/src/go/pt-mongodb-summary/main_test.go +++ b/src/go/pt-mongodb-summary/main_test.go @@ -8,9 +8,9 @@ import ( "time" "github.com/pborman/getopt" + "github.com/stretchr/testify/require" tu "github.com/percona/percona-toolkit/src/go/internal/testutils" - "github.com/percona/percona-toolkit/src/go/mongolib/proto" ) func TestGetHostInfo(t *testing.T) { @@ -49,6 +49,18 @@ func TestGetHostInfo(t *testing.T) { } } +func TestGetHostInfoResult(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + client, err := tu.TestClient(ctx, tu.MongoDBShard1PrimaryPort) + require.NoError(t, err, "cannot get a new MongoDB client") + + host, err := getHostInfo(ctx, client) + require.NoError(t, err, "getHostInfo error") + require.NotEmpty(t, host) +} + func TestClusterWideInfo(t *testing.T) { testCases := []struct { name string @@ -85,16 +97,6 @@ func TestClusterWideInfo(t *testing.T) { } } -func addToCounters(ss proto.ServerStatus, increment int64) proto.ServerStatus { - ss.Opcounters.Command += increment - ss.Opcounters.Delete += increment - ss.Opcounters.GetMore += increment - ss.Opcounters.Insert += increment - ss.Opcounters.Query += increment - ss.Opcounters.Update += increment - return ss -} - func TestParseArgs(t *testing.T) { tests := []struct { args []string