-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathdb.serverStatus.txt
116 lines (74 loc) · 2.79 KB
/
db.serverStatus.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
=================
db.serverStatus()
=================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. method:: db.serverStatus()
Returns a :term:`document` that provides an overview of the
database process's state.
This command provides a wrapper around the database command
:dbcommand:`serverStatus`.
Compatibility
-------------
This method is available in deployments hosted in the following environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-atlas-support-no-free.rst
.. include:: /includes/fact-environments-onprem-only.rst
Behavior
--------
.. include:: /includes/extracts/serverStatus-method-projection.rst
For example, the following operation suppresses the ``repl``,
``metrics`` and ``locks`` information in the output.
.. code-block:: javascript
db.serverStatus( { repl: 0, metrics: 0, locks: 0 } )
The following example includes all :ref:`server-status-repl`
information in the output:
.. code-block:: javascript
db.serverStatus( { repl: 1 } )
Initialization
~~~~~~~~~~~~~~
The statistics reported by :method:`db.serverStatus()` are reset when
the :binary:`~bin.mongod` server is restarted. The :method:`db.serverStatus()`
command does not report some statistics until they have been
initialized by server events.
For example, after restarting the :binary:`~bin.mongod` server,
:method:`db.serverStatus()` won't return any values for ``findAndModify``.
.. code-block:: javascript
db.serverStatus().metrics.commands.findAndModify
// No results returned
After you run an update query, subsequent calls to
:method:`db.serverStatus()` display the expected metrics.
.. code-block:: javascript
:copyable: false
{
"arrayFilters" : NumberLong(0),
"failed" : NumberLong(0),
"pipeline" : NumberLong(0),
"total" : NumberLong(1)
}
.. note::
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:
.. code-block:: javascript
db.serverStatus().metrics.commands.update.pipeline
Returns:
.. code-block:: javascript
:copyable: false
TypeError: db.serverStatus(...).metrics.commands.update is undefined :
@(shell):1:1
Include ``mirroredReads``
~~~~~~~~~~~~~~~~~~~~~~~~~
By default, the :serverstatus:`mirroredReads` information is not included in
the output. To return :serverstatus:`mirroredReads` information, you must
explicitly specify the inclusion:
.. code-block:: javascript
db.serverStatus( { mirroredReads: 1 } )
Output
------
See :ref:`serverStatus Output <server-status-output>` for complete
documentation of the output of this function.