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 배포를 위한 완전 관리형 서비스
중요
이 명령은 M,0 M,2 M5 및 Flex 클러스터에서 지원되지 않습니다. 자세한 내용은 지원되지 않는 명령을 참조하세요.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
행동
기본적으로 db.serverStatus()
는 출력에서 다음을 제외합니다.
some content in the repl document.
mirroredReads document.
기본적으로 제외되는 필드를 포함하려면 명령에서 최상위 필드를 지정하고 이 필드를 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 repl 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.