Using Percona Toolkit pt-mongodb-summary

pt-mongodb-summaryThis blog post is another in the series on the Percona Server for MongoDB 3.4 bundle release. In this blog post, we’ll look at the pt-mongodb-summary tool in Percona Toolkit.

The pt-mongodb-summary tool from Percona Toolkit provides a quick at-a-glance overview of MongoDB and Percona Server for MongoDB instances. It is equivalent to pt-mysql-summary for MySQL. 

pt-mongodb-summary also collects information about a MongoDB cluster. It collects information from several sources to provide an overview of the cluster.

How It Works

The usage for the command is as follows:

pt-mongodb-summary [OPTIONS] [HOST[:PORT]]


  • -a, –auth-db: Specifies the database used to establish credentials and privileges with a MongoDB server. By default, the admin database is used.
  • -p, –password: Specifies the password to use when connecting to a server with authentication enabled. Do not add a space between the option and its value: -p<password>.
    If you specify the option without any value, pt-mongodb-summary will ask for the password interactively.
  • -u, –user: Specifies the user name for connecting to a server with authentication enabled.

By default, if you run pt-mongodb-summary without parameters, it tries to connect to the localhost on port 27017. It collects information about the MongoDB instances by running administration commands, and formatting the output.



The first thing the tool does is get the list of hosts connected to the specified MongoDB instance by running the listShards command. It also runs replSetGetStatus on every instance to collect the ID, type, and replica set for each instance.

This host

Next, it gathers information about the host it is connected to by grouping information collected from hostInfo, getCmdLineOpts, serverStatus and the OS process (by process ID). The result provides an overview of the running instance and the underlying OS.

Running ops

This section collects statistics by running the serverStatus command five times at regular intervals (every one second), and provides the minimum, maximum and average operation counters for insert, query, update, delete, getMore and command operations.


This collects information about security configurations by parsing the  getCmdLineOpts command and asking the admin.system.users, and admin.system.roles collections.


From the MongoDB website:

The oplog (operations log) is a special capped collection that keeps a rolling record of all operations that modify the data stored in your databases. MongoDB applies database operations on the primary and then records the operations on the primary’s oplog. The secondary members then copy and apply these operations in an asynchronous process. All replica set members contain a copy of the oplog, in the collection, which allows them to maintain the current state of the database.

How do we get the oplog info? The program collects statistics from the oplog for every host in the cluster, and returns the information on the statistics having the smaller TimeDiffHours  value.


This section provides information about the number of sharded/unsharded databases, collections and their size.The information is collected by running the listDatabases command, and then running collStats for every collection in every database.

Conditional Sections

You may notice not all sections appear all the time. This is because there are three main patterns:

Sharded Connection to Mongos

  • Instances
  • This host
  • Running ops
  • Security
  • Cluster-wide

ReplicaSet Connection

  • Instances (limited to the current Replica Set)
  • This host
  • Running ops
  • Security
  • Oplog

Standalone Connection

  • Instances (limited to this host)
  • This host
  • Running ops
  • Security

Output Example

The following is an example of the output for pt-mongodb-summary:

 The following is an output example when connected to a secondary in the replica set.