On this page
serverStatus
On this page
Definition
serverStatus
-
The
serverStatus
command returns a document that provides an overview of the database’s state. Monitoring applications can run this command at a regular interval to collect statistics about the instance.db.runCommand( { serverStatus: 1 } )
The value (i.e.
1
above) does not affect the operation of the command. Themongo
shell provides thedb.serverStatus()
wrapper for the command.See also
Much of the output of
serverStatus
is also displayed dynamically bymongostat
. See the mongostat command for more information.
Behavior
By default, serverStatus
excludes in its output some content in the repl document.
To include fields that are excluded by default, specify the top-level field and set it to 1
in the command. To exclude fields that are included by default, specify the top-level field and set to 0
in the command.
For example, the following operation suppresses the repl
, metrics
and locks
information in the output.
db.runCommand( { serverStatus: 1, repl: 0, metrics: 0, locks: 0 } )
The following example includes all repl information in the output:
db.runCommand( { serverStatus: 1, repl: 1 } )
Output
Note
The output fields vary depending on the version of MongoDB, underlying operating system platform, the storage engine, and the kind of node, including mongos
, mongod
or replica set member.
For the serverStatus
output specific to the version of your MongoDB, refer to the appropriate version of the MongoDB Manual.
- Starting in MongoDB 3.6.11,
serverStatus
includes in its output:metrics.repl.apply.batchSize
opReadConcernCounters
opWriteConcernCounters
(RequiresreportOpWriteConcernCountersInServerStatus
parameter set totrue
).
- Starting in MongoDB 3.6,
serverStatus
no longer outputs therangeDeleter
section. - Starting in MongoDB 3.0,
serverStatus
no longer outputs theworkingSet
,indexCounters
, andrecordStats
sections.
Instance Information
"host" : <string>,
"advisoryHostFQDNs" : <array>,
"version" : <string>,
"process" : <"mongod"|"mongos">,
"pid" : <num>,
"uptime" : <num>,
"uptimeMillis" : <num>,
"uptimeEstimate" : <num>,
"localTime" : ISODate(""),
host
-
The system’s hostname. In Unix/Linux systems, this should be the same as the output of the
hostname
command.
advisoryHostFQDNs
-
New in version 3.2.
An array of the system’s fully qualified domain names (FQDNs).
asserts
"asserts" : {
"regular" : <num>,
"warning" : <num>,
"msg" : <num>,
"user" : <num>,
"rollovers" : <num>
},
asserts
-
A document that reports on the number of assertions raised since the MongoDB process started. While assert errors are typically uncommon, if there are non-zero values for the
asserts
, you should check the log file for more information. In many cases, these errors are trivial, but are worth investigating.
asserts.
regular
-
The number of regular assertions raised since the MongoDB process started. Check the log file for more information about these messages.
asserts.
warning
-
The number of warnings raised since the MongoDB process started. Check the log file for more information about these warnings.
asserts.
msg
-
The number of message assertions raised since the MongoDB process started. Check the log file for more information about these messages.
asserts.
user
-
The number of “user asserts” that have occurred since the last time the MongoDB process started. These are errors that user may generate, such as out of disk space or duplicate key. You can prevent these assertions by fixing a problem with your application or deployment. Check the MongoDB log for more information.
asserts.
rollovers
-
The number of times that the rollover counters have rolled over since the last time the MongoDB process started. The counters will rollover to zero after 230 assertions. Use this value to provide context to the other values in the
asserts
data structure.
backgroundFlushing
"backgroundFlushing" : {
"flushes" : <num>,
"total_ms" : <num>,
"average_ms" : <num>,
"last_ms" : <num>,
"last_finished" : ISODate("...")
},
Note
backgroundFlushing
information only appears for instances that use the MMAPv1 storage engine.
backgroundFlushing
-
A document that reports on the
mongod
process’s periodic writes to disk. Consider these values if you have concerns about write performance and journaling.
backgroundFlushing.
flushes
-
The number of times the database has flushed all writes to disk. This value will grow as database runs for longer periods of time.
backgroundFlushing.
total_ms
-
The total number of milliseconds (ms) that the
mongod
processes have spent writing (i.e. flushing) data to disk. Becausetotal_ms
is an absolute value, consider theflushes
andaverage_ms
values to provide context.
backgroundFlushing.
average_ms
-
The average time in milliseconds for each flush to disk, calculated by dividing
total_ms
byflushes
.The
average_ms
is more likely to to represent a “normal” time as the value of theflushes
increases. However, abnormal data can skew this value. Use thebackgroundFlushing.last_ms
to check that a high average is not skewed by transient historical issue or a random write distribution.
backgroundFlushing.
last_ms
-
The amount of time, in milliseconds, that the last flush operation took to complete. Use this value to verify that the current performance of the server is in line with the historical data provided by
backgroundFlushing.average_ms
andbackgroundFlushing.total_ms
.
backgroundFlushing.
last_finished
-
The timestamp of the last completed flush operation in the ISODate format. If this value is more than a few minutes past your server’s current time and accounting for differences in time zone, restarting the database may result in some data loss.
Also consider ongoing operations that might skew this value by routinely blocking write operations.