db.serverStatus()
db.serverStatus()
Returns a ドキュメント that provides an overview of the database process's state.
This command provides a wrapper around the database command
serverStatus
.
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
重要
このコマンドは、M0 、M2 、M5 、および Flex クラスターではサポートされていません。詳細については、「 サポートされていないコマンド 」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
動作
デフォルトでは、db.serverStatus()
出力から以下が除外されます:
デフォルトで除外されるフィールドを含めるには、最上位フィールドを指定し、コマンドで 1
に設定します。デフォルトで含まれるフィールドを除外するには、フィールドを指定して 0 に設定します。最上位フィールドまたは埋め込みフィールドのいずれかを指定できます。
For example, the following operation suppresses the repl
,
metrics
and locks
information in the output.
db.serverStatus( { repl: 0, metrics: 0, locks: 0 } )
The following example includes all レプラー information in the output:
db.serverStatus( { repl: 1 } )
初期化
The statistics reported by db.serverStatus()
are reset when
the mongod
server is restarted. The db.serverStatus()
command does not report some statistics until they have been
initialized by server events.
For example, after restarting the mongod
server,
db.serverStatus()
won't return any values for findAndModify
.
db.serverStatus().metrics.commands.findAndModify // No results returned
After you run an update query, subsequent calls to
db.serverStatus()
display the expected metrics.
{ "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.
If there haven't been any document updates yet:
db.serverStatus().metrics.commands.update.pipeline
次の値を返します。
TypeError: db.serverStatus(...).metrics.commands.update is undefined : @(shell):1:1
mirroredReads
を含む
By default, the mirroredReads
information is not included in
the output. To return mirroredReads
information, you must
explicitly specify the inclusion:
db.serverStatus( { mirroredReads: 1 } )
出力
See serverStatus Output for complete documentation of the output of this function.