diff --git a/doc/mloginfo.rst b/doc/mloginfo.rst index abdc36fd..927e21ad 100644 --- a/doc/mloginfo.rst +++ b/doc/mloginfo.rst @@ -16,9 +16,10 @@ Usage mloginfo [-h] [--version] logfile [--verbose] [--queries] [--restarts] [--distinct] [--connections] [--rsstate] + [--clients] + [--cursors] [--storagestats] [--transactions] [--tsort {duration}] - [--cursor] General Parameters ~~~~~~~~~~~~~~~~~~ @@ -142,53 +143,6 @@ example: This option has no effect unless ``--queries`` is also specified. -Transactions (``--transactions``) ---------------------------------- - -The transaction section will parse the log file to find information related -to transactions (MongoDB 4.0+). ``autocommit`` indicates whether ``autocommit`` -was enabled for a transaction. The ``readConcern`` information is fetched -either from ``OperationContext`` or ``_txnResourceStash``. ``TimeActiveMicros`` -and ``TimeInactiveMicros`` denote the number of micros active and inactive -during the span of the transaction. The ``duration`` field includes the value -in milliseconds and indicates the amount of time taken by each transaction. - -For example: - -.. code-block:: bash - - mloginfo mongod.log --transactions - -In addition to the default information, this command will also output the -``TRANSACTIONS`` section: - -.. code-block:: bash - - TRANSACTION - - DATETIME TXNNUMBER AUTOCOMMIT READCONCERN TIMEACTIVEMICROS TIMEINACTIVEMICROS DURATION - - 2019-06-18T12:31:03.180+0100 1 false "snapshot" 11142 3 7 - 2019-03-18T12:31:03.180+0100 2 false "snapshot" 11143 4 6 - 2019-07-18T12:31:03.180+0100 3 false "snapshot" 11144 3 4 - 2019-08-18T12:31:03.180+0100 4 false "snapshot" 11145 4 7 - 2019-06-18T12:31:03.180+0100 5 false "snapshot" 11146 3 3 - -``--tsort`` -^^^^^^^^^^^ - -This option can be used to sort the results of the ``--transaction`` table, -along with 'duration' keyword. - -For example: - -.. code-block:: bash - - mloginfo mongod.log --transaction --tsort duration - -This option has no effect unless it is specified between ``--transaction`` and -``duration`` is specified. - Restarts (``--restarts``) ------------------------- @@ -314,10 +268,57 @@ state changes. Oct 07 23:23:32 example.com:27018 RECOVERING Oct 07 23:23:34 example.com:27018 SECONDARY -Cursor (``--cursor``) +Transactions (``--transactions``) +--------------------------------- + +The transaction section will parse the log file to find information related +to transactions (MongoDB 4.0+). ``autocommit`` indicates whether ``autocommit`` +was enabled for a transaction. The ``readConcern`` information is fetched +either from ``OperationContext`` or ``_txnResourceStash``. ``TimeActiveMicros`` +and ``TimeInactiveMicros`` denote the number of micros active and inactive +during the span of the transaction. The ``duration`` field includes the value +in milliseconds and indicates the amount of time taken by each transaction. + +For example: + +.. code-block:: bash + + mloginfo mongod.log --transactions + +In addition to the default information, this command will also output the +``TRANSACTIONS`` section: + +.. code-block:: bash + + TRANSACTION + + DATETIME TXNNUMBER AUTOCOMMIT READCONCERN TIMEACTIVEMICROS TIMEINACTIVEMICROS DURATION + + 2019-06-18T12:31:03.180+0100 1 false "snapshot" 11142 3 7 + 2019-03-18T12:31:03.180+0100 2 false "snapshot" 11143 4 6 + 2019-07-18T12:31:03.180+0100 3 false "snapshot" 11144 3 4 + 2019-08-18T12:31:03.180+0100 4 false "snapshot" 11145 4 7 + 2019-06-18T12:31:03.180+0100 5 false "snapshot" 11146 3 3 + +``--tsort`` +^^^^^^^^^^^ + +This option can be used to sort the results of the ``--transaction`` table, +along with 'duration' keyword. + +For example: + +.. code-block:: bash + + mloginfo mongod.log --transaction --tsort duration + +This option has no effect unless it is specified between ``--transaction`` and +``duration`` is specified. + +Cursors (``--cursors``) ----------------------------------------- -Outputs information if the cursor was reaped for exceeding the transaction +Outputs information if a cursor was reaped for exceeding the transaction timeout. The timestamp of transaction, Cursor ID, and the time at which the cursor was reaped is captured from the logs. @@ -325,7 +326,7 @@ For example: .. code-block:: bash - mloginfo mongod.log --cursor + mloginfo mongod.log --cursors .. code-block:: bash @@ -340,7 +341,7 @@ For example: Storage Stats (``--storagestats``) ----------------------------------------- -Outputs the information about the storage statistics for slow transactions. +Outputs information about the storage statistics for slow transactions. For example: @@ -358,5 +359,5 @@ For example: local.myCollection insert None None None None local.myCollection update None None None None local1.myCollection insert None None None None - invoice-prod.invoices insert 12768411 22233323 86313 12344 - invoice-prod.invoices insert 12868411 22233323 86313 12344 + invoice-prod.invoices insert 12768411 22233323 86313 12344 + invoice-prod.invoices insert 12868411 22233323 86313 12344 diff --git a/mtools/mloginfo/sections/__init__.py b/mtools/mloginfo/sections/__init__.py index 0fc5b5b8..74750903 100644 --- a/mtools/mloginfo/sections/__init__.py +++ b/mtools/mloginfo/sections/__init__.py @@ -1,10 +1,10 @@ from .clients_section import ClientSection from .connection_section import ConnectionSection -from .cursor_section import CursorSection +from .cursors_section import CursorSection from .distinct_section import DistinctSection from .query_section import QuerySection from .restart_section import RestartSection from .rs_info_section import RsInfoSection from .rs_state_section import RsStateSection from .storagestats_section import StorageStatsSection -from .transaction_section import TransactionSection \ No newline at end of file +from .transactions_section import TransactionSection \ No newline at end of file diff --git a/mtools/mloginfo/sections/cursor_section.py b/mtools/mloginfo/sections/cursors_section.py similarity index 95% rename from mtools/mloginfo/sections/cursor_section.py rename to mtools/mloginfo/sections/cursors_section.py index 3e3bb478..af823541 100644 --- a/mtools/mloginfo/sections/cursor_section.py +++ b/mtools/mloginfo/sections/cursors_section.py @@ -15,19 +15,19 @@ def op_or_cmd(le): class CursorSection(BaseSection): """CursorSection class.""" - name = 'cursor' + name = 'cursors' def __init__(self, mloginfo): BaseSection.__init__(self, mloginfo) - helptext = 'outputs statistics about cursor' - self.mloginfo.argparser_sectiongroup.add_argument('--cursor', + helptext = 'outputs statistics about cursors' + self.mloginfo.argparser_sectiongroup.add_argument('--cursors', action='store_true', help=helptext) @property def active(self): """Return boolean if this section is active.""" - return self.mloginfo.args['cursor'] + return self.mloginfo.args['cursors'] def run(self): """Run this section and print out information.""" diff --git a/mtools/mloginfo/sections/transaction_section.py b/mtools/mloginfo/sections/transactions_section.py similarity index 100% rename from mtools/mloginfo/sections/transaction_section.py rename to mtools/mloginfo/sections/transactions_section.py diff --git a/mtools/test/test_mloginfo.py b/mtools/test/test_mloginfo.py index d4646b2a..4c2d3e0b 100644 --- a/mtools/test/test_mloginfo.py +++ b/mtools/test/test_mloginfo.py @@ -316,10 +316,10 @@ def test_transactions_output(self): assert any(map(lambda line: 'TRANSACTIONS' in line, lines)) assert any(map(lambda line: line.startswith('DATETIME'), lines)) - def test_cursor_output(self): + def test_cursors_output(self): # different log file logfile_path = "mtools/test/logfiles/mongod_4.0.10_reapedcursor.log" - self.tool.run('%s --cursor' % logfile_path) + self.tool.run('%s --cursors' % logfile_path) output = sys.stdout.getvalue() lines = output.splitlines() assert any('CURSOR' in line for line in lines)