[SERVER-10319] [mongostat] --discover option does not respect --rowcount (-n) output limitation Created: 24/Jul/13  Updated: 22/Aug/14  Resolved: 10/Oct/13

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: None
Fix Version/s: 2.5.3

Type: Bug Priority: Major - P3
Reporter: Sam Kleinman (Inactive) Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-10407 mongostat --discover should wait one ... Closed
is depended on by DOCS-1925 Document: [mongostat] --discover opti... Closed
Duplicate
is duplicated by SERVER-8163 mongostat rowcount option not working... Closed
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

If you run mongostat with the --discover option, mongostat will not respect the --rowcount (or -n) option, and continue to output until ^C'd.

mongostat should either respect --rowcount when running with --discover, otherwise it should produce an incompatible argument error (which should also be documented.)



 Comments   
Comment by auto [ 10/Oct/13 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-10319 Make mongostat --discover respect --rowcount
Branch: master
https://github.com/mongodb/mongo/commit/5784cd972939a8bc54e7a2b8492e5edf94c03514

Comment by Eric Daniels (Inactive) [ 25/Jul/13 ]

I think that is probably a better solution. Where would we draw the line though with --discover since it could be finding more on each iteration? In that case maybe it is better to say incompatible arguments for --discover but keep it working for multiple hosts?

Comment by Daniel Pasette (Inactive) [ 25/Jul/13 ]

It's not the difficulty of the change, it's whether the behavior is desirable. It often takes a couple iterations for the mongostat program to get useful data from a cluster, so would --rowcount indicate the first n rows which have complete data? Hold off on merging this just yet.

Comment by Eric Daniels (Inactive) [ 25/Jul/13 ]

Pull Request:
https://github.com/mongodb/mongo/pull/462

Comment by Eric Daniels (Inactive) [ 25/Jul/13 ]

I don't think that would be necessary. runMany() is just called instead of runNormal() which tracks rows printed but never limits it to rowcount/n. These are the only changes needed.

--- a/src/mongo/tools/stat.cpp
+++ b/src/mongo/tools/stat.cpp
@@ -448,11 +448,12 @@ namespace mongo {
 
             sleepsecs(1);
 
-            int row = 0;
+            int rowCount = getParam( "rowcount" , 0 );
+            int rowNum = 0;
             bool discover = hasParam( "discover" );
             int maxLockedDbWidth = 0;
 
-            while ( 1 ) {
+            while ( rowCount == 0 || rowNum < rowCount ) {
                 sleepsecs( (int)ceil(_statUtil.getSeconds()) );
 
                 // collect data
@@ -532,7 +533,7 @@ namespace mongo {
                 cout << endl;
 
                 //    header
-                if ( row++ % 5 == 0 && ! biggest.isEmpty() ) {
+                if ( rowNum++ % 5 == 0 && ! biggest.isEmpty() ) {
                     cout << setw( longestHost ) << "" << "\t";
                     printHeaders( biggest );
                 }

Comment by Daniel Pasette (Inactive) [ 24/Jul/13 ]

I think the correct behavior here is to error out with a message and to document.

Generated at Thu Feb 08 03:22:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.