On this page
mongotop
On this page
macOS Sierra and Go 1.6 Incompatibility
Users running on macOS Sierra require the 3.2.10 or newer version of mongotop.
Description
mongotop provides a method to track the amount of time a MongoDB instance mongod spends reading and writing data. mongotop provides statistics on a per-collection level. By default, mongotop returns values every second.
Run mongotop from the system command line, not the mongo shell.
Syntax
Default
mongotop [frequency]
You can run mongotop without any command-line options to connect to the mongod instance running on the localhost port 27017. By default, mongotop returns values every second.
mongotop
To have mongotop report every 30 seconds, specify the time:
mongotop 30
When connected to a mongod instance, the program reports first on the connection and then reports on the statistics at the configured frequency.
2019-04-29T15:35:27.785-0400 connected to: 127.0.0.1
ns total read write <timestamp>
<db.collection> 81802ms 0ms 81802ms
...
Command Line Options
mongotop [options] [frequency]
You can run mongotop with various command-line options.
For example, to connect mongotop to a mongod instance running on a remote host mongodb0.example.com and report every 30 seconds:
You can include the desired frequency of reporting (in this example, 30 seconds) and the
--urioption to specify the host and port:mongotop 30 --uri mongodb://mongodb0.example.com:27017 [additional options]If the
mongodinstance requires authentication, you can specify the user, password, and authentication database as part of the URI connection string:mongotop 30 --uri mongodb://user:password@mongodb0.example.com:27017/?authSource=admin [additional options]The user running
mongotopmust have theserverStatusandtopprivileges.For more information on the URI connection string, see
--uri.Alternatively, you can use the
--hostand--portoptions to specify the host and port:mongotop 30 --host mongodb0.example.com --port 27017 [additional options]If the
mongodinstance requires authentication, you can specify the user-u, password-p, and the authentication database--authenticationDatabase.mongotop 30 --host mongodb0.example.com --port 27017 -u user -p password --authenticationDatabase admin [additional options]The user running
mongotopmust have theserverStatusandtopprivileges.
For more information on the options available, see Options.
When connected to a mongod instance, the program reports first on the connection and then reports on the statistics at the configured frequency.
2019-04-29T15:35:27.785-0400 connected to: 127.0.0.1
ns total read write <timestamp>
<db.collection> 81802ms 0ms 81802ms
...
Required Access
In order to connect to a mongod that enforces authorization, the connecting user must have the serverStatus and top privileges.
The built-in role clusterMonitor provides these privileges.
Options
--verbose,-v-
Increases the amount of internal reporting returned on standard output or in log files. Increase the verbosity with the
-vform by including the option multiple times, (e.g.-vvvvv.)
--quiet-
Runs mongotop in a quiet mode that attempts to limit the amount of output.
This option suppresses:
- output from database commands
- replication activity
- connection accepted events
- connection closed events
--uri<connectionString>-
New in version 3.4.6.
Specify a resolvable URI connection string to connect to the MongoDB deployment.
--uri "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"For more information on the components of the connection string, see the Connection String URI Format documentation.
Important
The following command-line options cannot be used in conjunction with
--urioption:--host--port--username--password(if the URI connection string also includes the password)--authenticationDatabase--authenticationMechanism
Instead, specify these options as part of your
--uriconnection string.
--host<hostname><:port>,-h<hostname><:port>-
Default: localhost:27017
Specifies a resolvable hostname for the
mongodto which to connect. By default, the mongotop attempts to connect to a MongoDB instance running on the localhost on port number27017.To connect to a replica set, specify the
replSetNameand a seed list of set members, as in the following:--host <replSetName>/<hostname1><:port>,<hostname2><:port>,<...>When specifying the replica set list format, mongotop always connects to the primary.
You can also connect to any single member of the replica set by specifying the host and port of only that member:
--host <hostname1><:port>Changed in version 3.0.0: If you use IPv6 and use the
<address>:<port>format, you must enclose the portion of an address and port combination in brackets (e.g.[<address>]).If connected to a replica set where the primary is not reachable, mongotop returns an error message.
--port<port>-
Default: 27017
Specifies the TCP port on which the MongoDB instance listens for client connections.
--ipv6-
Removed in version 3.0.
Enables IPv6 support and allows mongotop to connect to the MongoDB instance using an IPv6 network. Prior to MongoDB 3.0, you had to specify
--ipv6to use IPv6. In MongoDB 3.0 and later, IPv6 is always enabled.
--ssl-
New in version 2.6.
Enables connection to a
mongodormongosthat has TLS/SSL support enabled.For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .
--sslCAFile<filename>-
New in version 2.6.
Specifies the
.pemfile that contains the root certificate chain from the Certificate Authority. Specify the file name of the.pemfile using relative or absolute paths.Starting in version 3.4, if
--sslCAFileorssl.CAFileis not specified and you are not using x.509 authentication, the system-wide CA certificate store will be used when connecting to an TLS/SSL-enabled server.If using x.509 authentication,
--sslCAFileorssl.CAFilemust be specified.