db.serverStatus()データベース プロセスの状態の概要を示す ドキュメント を返します。
このコマンドは、データベース コマンド
serverStatusにラッパーを提供します。
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
重要
This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
動作
By default, db.serverStatus() excludes in its output:
repl ドキュメント内の一部のコンテンツ
mirroredReads ドキュメント。
デフォルトで除外されるフィールドを含めるには、最上位フィールドを指定し、コマンドで 1 に設定します。デフォルトで含まれるフィールドを除外するには、フィールドを指定して 0 に設定します。最上位フィールドまたは埋め込みフィールドのいずれかを指定できます。
たとえば、次の操作は、出力内の repl、metrics、および locks 情報を抑制します。
db.serverStatus( { repl: 0, metrics: 0, locks: 0 } )
次の例では、出力にすべての repl 情報が含まれます。
db.serverStatus( { repl: 1 } )
すべての任意フィールドを除外する
MongoDB 8.3 以降では、none: 1 を指定することで、db.serverStatus() の出力からすべての任意フィールドを除外できます。任意のフィールドをすべて除外した後、含めるフィールドを指定できます。
この例では、none を使用して最初にすべての任意フィールドを出力から除外し、次に locksドキュメントを含めます。
db.serverStatus({ none: 1, locks: 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" : Long(0), "failed" : Long(0), "pipeline" : Long(0), "total" : Long(1) }
注意
カウンターの増加が始まる前に特定のオブジェクトが照会された場合、db.serverStatus() メソッドはエラーを返します。
ドキュメントの更新がまだない場合:
db.serverStatus().metrics.commands.update.pipeline
次の値を返します。
TypeError: db.serverStatus(...).metrics.commands.update is undefined : @(shell):1:1
次を含みます: mirroredReads
デフォルトでは、 mirroredReads情報は出力に含まれていません。 mirroredReads情報を返すには、包含を明示的に指定する必要があります。
db.serverStatus( { mirroredReads: 1 } )
WiredTiger のバージョンを返す
WiredTigerストレージエンジンのバージョンを返すには、wiredTiger.version フィールドにアクセスします。
db.serverStatus().wiredTiger.version
出力
この関数の出力の完全なドキュメントについては、「serverStatus 出力」を参照してください。