On this page本页内容
db.serverStatus()
Returns a document that provides an overview of the database process's state.返回提供数据库进程状态概述的文档。
This command provides a wrapper around the database command 此命令提供数据库命令serverStatus
.serverStatus
的包装。
By default, 默认情况下,db.serverStatus()
excludes in its output:db.serverStatus()
在其输出中排除:
To include fields that are excluded by default, specify the top-level field and set it to 要包括默认情况下排除的字段,请指定顶级字段并在命令中将其设置为1
in the command. 1
。To exclude fields that are included by default, specify the top-level field and set to 要排除默认情况下包含的字段,请指定顶级字段并在命令中设置为0
in the command.0
。
For example, the following operation suppresses the 例如,以下操作抑制输出中的repl
, metrics
and locks
information in the output.repl
、metrics
和locks
信息。
db.serverStatus( { repl: 0, metrics: 0, locks: 0 } )
The following example includes all repl information in the output:以下示例包括输出中的所有repl信息:
db.serverStatus( { repl: 1 } )
The statistics reported by 当db.serverStatus()
are reset when the mongod
server is restarted. mongod
服务器重新启动时,db.serverStatus()
报告的统计信息将被重置。The db.serverStatus()
command does not report some statistics until they have been initialized by server events.db.serverStatus()
命令不会报告某些统计信息,直到它们被服务器事件初始化。
For example, after restarting the 例如,在重新启动mongod
server, db.serverStatus()
won't return any values for findAndModify
.mongod
服务器后,db.serverStatus()
不会返回findAndModify
的任何值。
db.serverStatus().metrics.commands.findAndModify
// No results returned
After you run an update query, subsequent calls to 运行更新查询后,对db.serverStatus()
display the expected metrics.db.serverStatus()
的后续调用将显示预期的指标。
{ "arrayFilters" : NumberLong(0), "failed" : NumberLong(0), "pipeline" : NumberLong(0), "total" : NumberLong(1) }
The 如果在计数器开始递增之前查询了特定对象,db.serverStatus()
method returns an error if a specific object is queried before the counters have begun to increment.db.serverStatus()
方法将返回一个错误。
If there haven't been any document updates yet:如果还没有任何文档更新:
db.serverStatus().metrics.commands.update.pipeline
Returns:退货:
TypeError: db.serverStatus(...).metrics.commands.update is undefined : @(shell):1:1
mirroredReads
By default, the 默认情况下,输出中不包含mirroredReads
information (available starting in version 4.4) is not included in the output. mirroredReads
信息(从4.4版开始可用)。To return 要返回mirroredReads
information, you must explicitly specify the inclusion:mirroredReads
信息,必须明确指定包含:
db.serverStatus( { mirroredReads: 1 } )
latchAnalysis
By default, the 默认情况下,输出中不包含latchAnalysis
information (available starting in version 4.4) is not included in the output. latchAnalysis
信息(从4.4版开始可用)。To return 要返回latchAnalysis
information, you must explicitly specify the inclusion:latchAnalysis
信息,必须明确指定包含:
db.serverStatus( { latchAnalysis: 1 } )
See serverStatus Output for complete documentation of the output of this function.有关此函数输出的完整文档,请参阅serverStatus输出。