Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

338 lines (212 sloc) 9.464 kB
.. _mongostat:
=============
``mongostat``
=============
.. default-domain:: mongodb
.. |tool-binary| replace:: mongostat
Synopsis
--------
The :program:`mongostat` utility provides a quick overview of the
status of a currently running :program:`mongod`
or :program:`mongos`
instance. :program:`mongostat` is functionally similar to the
UNIX/Linux file system utility ``vmstat``, but provides data regarding
:program:`mongod` and :program:`mongos` instances.
.. seealso::
For more information about monitoring MongoDB, see
:doc:`/administration/monitoring`.
For more background on various other MongoDB status outputs see:
- :doc:`/reference/command/serverStatus`
- :doc:`/reference/command/replSetGetStatus`
- :doc:`/reference/command/dbStats`
- :doc:`/reference/command/collStats`
For an additional utility that provides MongoDB metrics see
:doc:`mongotop </reference/program/mongotop>`.
Required Access
---------------
In order to connect to a :program:`mongod` that enforces authorization
with the :option:`--auth <mongod --auth>` option, specify the
:option:`--username <mongostat --username>` and :option:`--password
<mongostat --password>` options, and the connecting user must have the
:authaction:`serverStatus` privilege action on the cluster resources.
The built-in role :authrole:`clusterMonitor` provides this privilege as
well as other privileges. To create a role with just the privilege to
run :program:`mongostat`, see :ref:`create-role-for-mongostat`.
Options
-------
.. binary:: mongostat
.. program:: mongostat
.. include:: /includes/option/option-mongostat-help.rst
.. include:: /includes/option/option-mongostat-verbose.rst
.. include:: /includes/option/option-mongostat-version.rst
.. include:: /includes/option/option-mongostat-host.rst
.. include:: /includes/option/option-mongostat-port.rst
.. include:: /includes/option/option-mongostat-ipv6.rst
.. include:: /includes/option/option-mongostat-ssl.rst
.. include:: /includes/option/option-mongostat-sslCAFile.rst
.. include:: /includes/option/option-mongostat-sslPEMKeyFile.rst
.. include:: /includes/option/option-mongostat-sslPEMKeyPassword.rst
.. include:: /includes/option/option-mongostat-sslCRLFile.rst
.. include:: /includes/option/option-mongostat-sslAllowInvalidCertificates.rst
.. include:: /includes/option/option-mongostat-sslAllowInvalidHostnames.rst
.. include:: /includes/option/option-mongostat-sslFIPSMode.rst
.. include:: /includes/option/option-mongostat-username.rst
.. include:: /includes/option/option-mongostat-password.rst
.. include:: /includes/option/option-mongostat-authenticationDatabase.rst
.. include:: /includes/option/option-mongostat-authenticationMechanism.rst
.. include:: /includes/option/option-mongostat-gssapiServiceName.rst
.. include:: /includes/option/option-mongostat-gssapiHostName.rst
.. include:: /includes/option/option-mongostat-noheaders.rst
.. include:: /includes/option/option-mongostat-rowcount.rst
.. include:: /includes/option/option-mongostat-http.rst
.. include:: /includes/option/option-mongostat-discover.rst
.. include:: /includes/option/option-mongostat-all.rst
.. include:: /includes/option/option-mongostat-json.rst
.. include:: /includes/option/option-mongostat-<sleeptime>.rst
.. _mongostat-fields:
Fields
------
:program:`mongostat` returns values that reflect the operations over a
1 second period. When :command:`mongostat <sleeptime>` has a value
greater than 1, :program:`mongostat` averages the statistics to reflect
average operations per second.
:program:`mongostat` outputs the following fields:
.. describe:: inserts
The number of objects inserted into the database per second. If
followed by an asterisk (e.g. ``*``), the datum refers to a
replicated operation.
.. describe:: query
The number of query operations per second.
.. describe:: update
The number of update operations per second.
.. describe:: delete
The number of delete operations per second.
.. describe:: getmore
The number of get more (i.e. cursor batch) operations per second.
.. describe:: command
The number of commands per second. On :term:`slave` and
:term:`secondary` systems, :program:`mongostat` presents two values
separated by a pipe character (e.g. ``|``), in the form of
``local|replicated`` commands.
.. describe:: flushes
.. versionchanged:: 3.0.0
For the :ref:`storage-wiredtiger`, ``flushes`` refers to the number
of WiredTiger checkpoints triggered between each polling interval.
For the :ref:`storage-mmapv1`, ``flushes`` represents the number of
:term:`fsync` operations per second.
.. describe:: dirty
.. versionadded:: 3.0.0
Only for :ref:`storage-wiredtiger`. The percentage of the WiredTiger
cache with dirty bytes.
.. describe:: used
.. versionadded:: 3.0.0
Only for :ref:`storage-wiredtiger`. The percentage of the WiredTiger
cache that is in use.
.. describe:: mapped
.. versionchanged:: 3.0.0
Only for :ref:`storage-mmapv1`. The total amount of data mapped in
megabytes. This is the total data size at the time of the last
:program:`mongostat` call.
.. describe:: vsize
The amount of virtual memory in megabytes used by the process at
the time of the last :program:`mongostat` call.
.. describe:: non-mapped
.. versionchanged:: 3.0.0
Only for :ref:`storage-mmapv1`.
*Optional*. The total amount of virtual memory excluding all mapped memory at
the time of the last :program:`mongostat` call.
:program:`mongostat` only returns this value when started with the
:option:`--all <mongostat --all>` option.
.. describe:: res
The amount of resident memory in megabytes used by the process at
the time of the last :program:`mongostat` call.
.. describe:: faults
.. versionchanged:: 3.0.0
Only for :ref:`storage-mmapv1`. The number of page faults per second.
.. versionchanged:: 2.1
Before version 2.1, this value was only provided for MongoDB
instances running on Linux hosts.
.. describe:: locked
.. versionchanged:: 3.0.0
Only appears when :program:`mongostat` runs against pre-3.0
versions of MongoDB instances.
The percent of time in a global write lock.
.. versionchanged:: 2.2
The ``locked db`` field replaces the ``locked %`` field to
more appropriate data regarding the database specific locks in
version 2.2.
.. describe:: idx miss
.. versionchanged:: 3.0.0
Only for :ref:`storage-mmapv1`. The percent of index access attempts
that required a page fault to load a btree node. This is a sampled
value.
.. describe:: qr
The length of the queue of clients waiting to read data from the
MongoDB instance.
.. describe:: qw
The length of the queue of clients waiting to write data from the
MongoDB instance.
.. describe:: ar
The number of active clients performing read operations.
.. describe:: aw
The number of active clients performing write operations.
.. describe:: netIn
The amount of network traffic, in *bytes*, received by the MongoDB instance.
This includes traffic from :program:`mongostat` itself.
.. describe:: netOut
The amount of network traffic, in *bytes*, sent by the MongoDB instance.
This includes traffic from :program:`mongostat` itself.
.. describe:: conn
The total number of open connections.
.. describe:: set
The name, if applicable, of the replica set.
.. describe:: repl
The replication status of the member.
========= =========================
**Value** **Replication Type**
--------- -------------------------
M :term:`master`
SEC :term:`secondary`
REC recovering
UNK unknown
SLV :term:`slave`
RTR mongos process ("router")
ARB :term:`arbiter`
========= =========================
Usage
-----
In the first example, :program:`mongostat` will return data every
second for 20 seconds. :program:`mongostat` collects data from the
:program:`mongod` instance running on the localhost interface on
port 27017. All of the following invocations produce identical
behavior:
.. code-block:: sh
mongostat --rowcount 20 1
mongostat --rowcount 20
mongostat -n 20 1
mongostat -n 20
In the next example, :program:`mongostat` returns data every 5 minutes
(or 300 seconds) for as long as the program runs. :program:`mongostat`
collects data from the :program:`mongod` instance running on the
localhost interface on port ``27017``. Both of the following
invocations produce identical behavior.
.. code-block:: sh
mongostat --rowcount 0 300
mongostat -n 0 300
mongostat 300
In the following example, :program:`mongostat` returns data every 5
minutes for an hour (12 times.) :program:`mongostat` collects data
from the :program:`mongod` instance running on the localhost interface
on port 27017. Both of the following invocations produce identical
behavior.
.. code-block:: sh
mongostat --rowcount 12 300
mongostat -n 12 300
In many cases, using the :option:`--discover <mongostat --discover>`
will help provide a more complete snapshot of the state of an entire
group of machines. If a :program:`mongos` process connected to a
:term:`sharded cluster` is running on port ``27017`` of the local
machine, you can use the following form to return statistics from all
members of the cluster:
.. code-block:: sh
mongostat --discover
Jump to Line
Something went wrong with that request. Please try again.