1MONGOSTAT(1) mongodb-manual MONGOSTAT(1)
2
3
4
6 mongostat - MongoDB Use Statistics
7
9 The mongostat utility provides a quick overview of the status of a cur‐
10 rently running mongod or mongos instance. mongostat is functionally
11 similar to the UNIX/Linux file system utility vmstat, but provides data
12 regarding mongod and mongos instances.
13
14 SEE ALSO:
15 For more information about monitoring MongoDB, see http://docs.mon‐
16 godb.org/manual/administration/monitoring.
17
18 For more background on various other MongoDB status outputs see:
19
20 · http://docs.mongodb.org/manual/reference/command/serverStatus
21
22 · http://docs.mongodb.org/manual/reference/command/replSetGetStatus
23
24 · http://docs.mongodb.org/manual/reference/command/dbStats
25
26 · http://docs.mongodb.org/manual/reference/command/collStats
27
28 For an additional utility that provides MongoDB metrics see mongo‐
29 top.
30
32 In order to connect to a mongod that enforces authorization with the
33 --auth option, specify the --username and --password options, and the
34 user specified must have the serverStatus privilege action on the clus‐
35 ter resources.
36
37 The built-in role clusterMonitor provides this privilege as well as
38 other privileges. To create a role with just the privilege to run mon‐
39 gostat, see create-role-for-mongostat.
40
42 mongostat
43
44 mongostat
45
46 --help Returns information on the options and use of mongostat.
47
48 --verbose, -v
49 Increases the amount of internal reporting returned on standard
50 output or in log files. Increase the verbosity with the -v form
51 by including the option multiple times, (e.g. -vvvvv.)
52
53 --version
54 Returns the mongostat release number.
55
56 --host <hostname><:port>, -h <hostname><:port>
57 Default: localhost:27017
58
59 Specifies a resolvable hostname for the mongod to which to con‐
60 nect. By default, the mongostat attempts to connect to a MongoDB
61 instance running on the localhost on port number 27017.
62
63 To connect to a replica set, specify the replSetName and a seed
64 list of set members, as in the following:
65
66 <replSetName>/<hostname1><:port>,<hostname2><:port>,<...>
67
68 You can always connect directly to a single MongoDB instance by
69 specifying the host and port number directly.
70
71 Changed in version 3.0.0: If you use IPv6 and use the
72 <address>:<port> format, you must enclose the portion of an
73 address and port combination in brackets (e.g. [<address>]).
74
75
76 --port <port>
77 Default: 27017
78
79 Specifies the TCP port on which the MongoDB instance listens for
80 client connections.
81
82 --ipv6 Enables IPv6 support and allows the mongostat to connect to the
83 MongoDB instance using an IPv6 network. All MongoDB programs and
84 processes disable IPv6 support by default.
85
86 --ssl New in version 2.6.
87
88
89 Enables connection to a mongod or mongos that has SSL support
90 enabled.
91
92 The default distribution of MongoDB does not contain support for
93 SSL. For more information on MongoDB and SSL, see
94 http://docs.mongodb.org/manual/tutorial/configure-ssl.
95
96 --sslCAFile <filename>
97 New in version 2.6.
98
99
100 Specifies the .pem file that contains the root certificate chain
101 from the Certificate Authority. Specify the file name of the
102 .pem file using relative or absolute paths.
103
104 The default distribution of MongoDB does not contain support for
105 SSL. For more information on MongoDB and SSL, see
106 http://docs.mongodb.org/manual/tutorial/configure-ssl.
107
108 WARNING:
109 If the mongo shell or any other tool that connects to mongos
110 or mongod is run without --sslCAFile, it will not attempt to
111 validate server certificates. This results in vulnerability
112 to expired mongod and mongos certificates as well as to for‐
113 eign processes posing as valid mongod or mongos instances.
114 Ensure that you always specify the CA file against which
115 server certificates should be validated in cases where intru‐
116 sion is a possibility.
117
118 --sslPEMKeyFile <filename>
119 New in version 2.6.
120
121
122 Specifies the .pem file that contains both the SSL certificate
123 and key. Specify the file name of the .pem file using relative
124 or absolute paths.
125
126 This option is required when using the --ssl option to connect
127 to a mongod or mongos that has CAFile enabled without allowCon‐
128 nectionsWithoutCertificates.
129
130 The default distribution of MongoDB does not contain support for
131 SSL. For more information on MongoDB and SSL, see
132 http://docs.mongodb.org/manual/tutorial/configure-ssl.
133
134 --sslPEMKeyPassword <value>
135 New in version 2.6.
136
137
138 Specifies the password to de-crypt the certificate-key file
139 (i.e. --sslPEMKeyFile). Use the --sslPEMKeyPassword option only
140 if the certificate-key file is encrypted. In all cases, the mon‐
141 gostat will redact the password from all logging and reporting
142 output.
143
144 If the private key in the PEM file is encrypted and you do not
145 specify the --sslPEMKeyPassword option, the mongostat will
146 prompt for a passphrase. See ssl-certificate-password.
147
148 The default distribution of MongoDB does not contain support for
149 SSL. For more information on MongoDB and SSL, see
150 http://docs.mongodb.org/manual/tutorial/configure-ssl.
151
152 --sslCRLFile <filename>
153 New in version 2.6.
154
155
156 Specifies the .pem file that contains the Certificate Revocation
157 List. Specify the file name of the .pem file using relative or
158 absolute paths.
159
160 The default distribution of MongoDB does not contain support for
161 SSL. For more information on MongoDB and SSL, see
162 http://docs.mongodb.org/manual/tutorial/configure-ssl.
163
164 --sslAllowInvalidCertificates
165 New in version 2.6.
166
167
168 Bypasses the validation checks for server certificates and
169 allows the use of invalid certificates. When using the allowIn‐
170 validCertificates setting, MongoDB logs as a warning the use of
171 the invalid certificate.
172
173 The default distribution of MongoDB does not contain support for
174 SSL. For more information on MongoDB and SSL, see
175 http://docs.mongodb.org/manual/tutorial/configure-ssl.
176
177 --sslAllowInvalidHostnames
178 New in version 3.0.
179
180
181 Disables the validation of the hostnames in SSL certificates.
182 Allows mongostat to connect to MongoDB instances if the hostname
183 their certificates do not match the specified hostname.
184
185 --sslFIPSMode
186 New in version 2.6.
187
188
189 Directs the mongostat to use the FIPS mode of the installed
190 OpenSSL library. Your system must have a FIPS compliant OpenSSL
191 library to use the --sslFIPSMode option.
192
193 NOTE:
194 FIPS Compatible SSL is available only in MongoDB Enterprise.
195 See http://docs.mongodb.org/manual/tutorial/configure-fips
196 for more information.
197
198 --username <username>, -u <username>
199 Specifies a username with which to authenticate to a MongoDB
200 database that uses authentication. Use in conjunction with the
201 --password and --authenticationDatabase options.
202
203 --password <password>, -p <password>
204 Specifies a password with which to authenticate to a MongoDB
205 database that uses authentication. Use in conjunction with the
206 --username and --authenticationDatabase options.
207
208 If you do not specify an argument for --password, mongostat will
209 prompt interactively for a password on the console.
210
211 --authenticationDatabase <dbname>
212 New in version 2.4.
213
214
215 Specifies the database that holds the user's credentials.
216
217 --authenticationDatabase is required for mongod and mongos
218 instances that use authentication.
219
220 --authenticationMechanism <name>
221 Default: MONGODB-CR
222
223 New in version 2.4.
224
225
226 Changed in version 2.6: Added support for the PLAIN and MON‐
227 GODB-X509 authentication mechanisms.
228
229
230 Specifies the authentication mechanism the mongostat instance
231 uses to authenticate to the mongod or mongos.
232
233 ┌─────────────┬────────────────────────────┐
234 │Value │ Description │
235 ├─────────────┼────────────────────────────┤
236 │MONGODB-CR │ MongoDB challenge/response │
237 │ │ authentication. │
238 ├─────────────┼────────────────────────────┤
239 │MONGODB-X509 │ MongoDB SSL certificate │
240 │ │ authentication. │
241 ├─────────────┼────────────────────────────┤
242 │PLAIN │ External authentication │
243 │ │ using LDAP. You can also │
244 │ │ use PLAIN for authenticat‐ │
245 │ │ ing in-database users. │
246 │ │ PLAIN transmits passwords │
247 │ │ in plain text. This mecha‐ │
248 │ │ nism is available only in │
249 │ │ MongoDB Enterprise. │
250 ├─────────────┼────────────────────────────┤
251 │GSSAPI │ External authentication │
252 │ │ using Kerberos. This mech‐ │
253 │ │ anism is available only in │
254 │ │ MongoDB Enterprise. │
255 └─────────────┴────────────────────────────┘
256
257 --gssapiServiceName
258 New in version 2.6.
259
260
261 Specify the name of the service using GSSAPI/Kerberos. Only
262 required if the service does not use the default name of mon‐
263 godb.
264
265 This option is available only in MongoDB Enterprise.
266
267 --gssapiHostName
268 New in version 2.6.
269
270
271 Specify the hostname of a service using GSSAPI/Kerberos. Only
272 required if the hostname of a machine does not match the host‐
273 name resolved by DNS.
274
275 This option is available only in MongoDB Enterprise.
276
277 --noheaders
278 Disables the output of column or field names.
279
280 --rowcount <number>, -n <number>
281 Controls the number of rows to output. Use in conjunction with
282 the sleeptime argument to control the duration of a mongostat
283 operation.
284
285 Unless --rowcount is specified, mongostat will return an infi‐
286 nite number of rows (e.g. value of 0.)
287
288 --http Configures mongostat to collect data using the HTTP interface
289 rather than a raw database connection.
290
291 --discover
292 Discovers and reports on statistics from all members of a
293 replica set or sharded cluster. When connected to any member of
294 a replica set, --discover all non-hidden members of the replica
295 set. When connected to a mongos, mongostat will return data from
296 all shards in the cluster. If a replica set provides a shard in
297 the sharded cluster, mongostat will report on non-hidden members
298 of that replica set.
299
300 The mongostat --host option is not required but potentially use‐
301 ful in this case.
302
303 Changed in version 2.6: When running with --discover, mongostat
304 now respects :option:--rowcount`.
305
306
307 --all Configures mongostat to return all optional fields.
308
309 --json New in version 3.0.0.
310
311
312 Returns output for mongostat in JSON format.
313
314 <sleeptime>
315 The final argument is the length of time, in seconds, that mon‐
316 gostat waits in between calls. By default mongostat returns one
317 call every second.
318
319 mongostat returns values that reflect the operations over a 1
320 second period. For values of <sleeptime> greater than 1, mongo‐
321 stat averages data to reflect average operations per second.
322
324 mongostat returns values that reflect the operations over a 1 second
325 period. When mongostat <sleeptime> has a value greater than 1, mongo‐
326 stat averages the statistics to reflect average operations per second.
327
328 mongostat outputs the following fields:
329
330 inserts
331 The number of objects inserted into the database per second. If
332 followed by an asterisk (e.g. *), the datum refers to a repli‐
333 cated operation.
334
335 query The number of query operations per second.
336
337 update The number of update operations per second.
338
339 delete The number of delete operations per second.
340
341 getmore
342 The number of get more (i.e. cursor batch) operations per sec‐
343 ond.
344
345 command
346 The number of commands per second. On slave and secondary sys‐
347 tems, mongostat presents two values separated by a pipe charac‐
348 ter (e.g. |), in the form of local|replicated commands.
349
350 flushes
351 The number of fsync operations per second.
352
353 mapped The total amount of data mapped in megabytes. This is the total
354 data size at the time of the last mongostat call.
355
356 size The amount of virtual memory in megabytes used by the process at
357 the time of the last mongostat call.
358
359 non-mapped
360 The total amount of virtual memory excluding all mapped memory
361 at the time of the last mongostat call.
362
363 res The amount of resident memory in megabytes used by the process
364 at the time of the last mongostat call.
365
366 faults Changed in version 2.1.
367
368
369 The number of page faults per second.
370
371 Before version 2.1 this value was only provided for MongoDB
372 instances running on Linux hosts.
373
374 locked The percent of time in a global write lock.
375
376 Changed in version 2.2: The locked db field replaces the locked
377 % field to more appropriate data regarding the database specific
378 locks in version 2.2.
379
380
381 locked db
382 New in version 2.2.
383
384
385 The percent of time in the per-database context-specific lock.
386 mongostat will report the database that has spent the most time
387 since the last mongostat call with a write lock.
388
389 This value represents the amount of time that the listed data‐
390 base spent in a locked state combined with the time that the
391 mongod spent in the global lock. Because of this, and the sam‐
392 pling method, you may see some values greater than 100%.
393
394 idx miss
395 The percent of index access attempts that required a page fault
396 to load a btree node. This is a sampled value.
397
398 qr The length of the queue of clients waiting to read data from the
399 MongoDB instance.
400
401 qw The length of the queue of clients waiting to write data from
402 the MongoDB instance.
403
404 ar The number of active clients performing read operations.
405
406 aw The number of active clients performing write operations.
407
408 netIn The amount of network traffic, in bytes, received by the MongoDB
409 instance.
410
411 This includes traffic from mongostat itself.
412
413 netOut The amount of network traffic, in bytes, sent by the MongoDB
414 instance.
415
416 This includes traffic from mongostat itself.
417
418 conn The total number of open connections.
419
420 set The name, if applicable, of the replica set.
421
422 repl The replication status of the member.
423
424 ┌──────┬───────────────────────────┐
425 │Value │ Replication Type │
426 ├──────┼───────────────────────────┤
427 │M │ master │
428 ├──────┼───────────────────────────┤
429 │SEC │ secondary │
430 ├──────┼───────────────────────────┤
431 │REC │ recovering │
432 ├──────┼───────────────────────────┤
433 │UNK │ unknown │
434 ├──────┼───────────────────────────┤
435 │SLV │ slave │
436 ├──────┼───────────────────────────┤
437 │RTR │ mongos process ("router") │
438 └──────┴───────────────────────────┘
439
441 In the first example, mongostat will return data every second for 20
442 seconds. mongostat collects data from the mongod instance running on
443 the localhost interface on port 27017. All of the following invocations
444 produce identical behavior:
445
446 mongostat --rowcount 20 1
447 mongostat --rowcount 20
448 mongostat -n 20 1
449 mongostat -n 20
450
451 In the next example, mongostat returns data every 5 minutes (or 300
452 seconds) for as long as the program runs. mongostat collects data from
453 the mongod instance running on the localhost interface on port 27017.
454 Both of the following invocations produce identical behavior.
455
456 mongostat --rowcount 0 300
457 mongostat -n 0 300
458 mongostat 300
459
460 In the following example, mongostat returns data every 5 minutes for an
461 hour (12 times.) mongostat collects data from the mongod instance run‐
462 ning on the localhost interface on port 27017. Both of the following
463 invocations produce identical behavior.
464
465 mongostat --rowcount 12 300
466 mongostat -n 12 300
467
468 In many cases, using the --discover will help provide a more complete
469 snapshot of the state of an entire group of machines. If a mongos
470 process connected to a sharded cluster is running on port 27017 of the
471 local machine, you can use the following form to return statistics from
472 all members of the cluster:
473
474 mongostat --discover
475
477 MongoDB Documentation Project
478
480 2011-2015
481
482
483
484
4853.0 January 30, 2015 MONGOSTAT(1)