db.serverStatus()
Nesta página
db.serverStatus()
Returns a documento that provides an overview of the database process's state.
This command provides a wrapper around the database command
serverStatus
.
Compatibilidade
Esse método está disponível em implantações hospedadas nos seguintes ambientes:
MongoDB Atlas: o serviço totalmente gerenciado para implantações do MongoDB na nuvem
Importante
Esse comando não é suportado em clusters M,0 M,2 M5 e Flex. Para obter mais informações, consulte Comandos não suportados.
MongoDB Enterprise: a versão autogerenciada e baseada em assinatura do MongoDB
MongoDB Community: uma versão com código disponível, de uso gratuito e autogerenciada do MongoDB
Comportamento
Por padrão, db.serverStatus()
exclui em sua saída:
some content in the repl document.
mirroredReads document.
Para incluir campos que são excluídos por padrão, especifique o campo de nível superior e defina-o para 1
no comando. Para excluir campos incluídos por padrão, especifique o campo e defina como 0. Você pode especificar campos incorporados ou de nível superior.
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 } )
Inicialização
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) }
Observação
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
Retorna:
TypeError: db.serverStatus(...).metrics.commands.update is undefined : @(shell):1:1
Incluir 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 } )
Saída
See serverStatus Output for complete documentation of the output of this function.