summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormike o'brien <mpobrien005@gmail.com>2015-02-09 16:43:27 -0500
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-02-09 17:40:29 -0500
commitc9756fd528cc009cfd83c5bcfe9e309344f5e781 (patch)
tree8d8c5f9b8fb1d6fa73b80a05562ac62b244cef5d
parent1dd33f490c47f8e4bc01f11931b62a463fe4fbca (diff)
downloadmongo-c9756fd528cc009cfd83c5bcfe9e309344f5e781.tar.gz
SERVER-17216 2.6 mongostat should not crash if connected to a 3.0 mongod, and warn if detected
Closes #922 Signed-off-by: Ramon Fernandez <ramon.fernandez@mongodb.com>
-rw-r--r--src/mongo/tools/stat.cpp11
-rw-r--r--src/mongo/tools/stat_util.cpp8
2 files changed, 16 insertions, 3 deletions
diff --git a/src/mongo/tools/stat.cpp b/src/mongo/tools/stat.cpp
index 30bb78252e1..002d8a4a5f0 100644
--- a/src/mongo/tools/stat.cpp
+++ b/src/mongo/tools/stat.cpp
@@ -151,6 +151,7 @@ namespace mongo {
return -1;
int maxLockedDbWidth = 0;
+ bool warned = false;
while (mongoStatGlobalParams.rowCount == 0 ||
rowNum < mongoStatGlobalParams.rowCount) {
@@ -169,6 +170,11 @@ namespace mongo {
try {
+ if ( !warned && now["storageEngine"].type() ) {
+ toolError() << "warning: detected a 3.0 mongod, some columns not applicable" << endl;
+ warned = true;
+ }
+
BSONObj out = _statUtil.doRow( prev , now );
// adjust width up as longer 'locked db' values appear
@@ -230,6 +236,7 @@ namespace mongo {
static void serverThread( shared_ptr<ServerState> state , int sleepTime) {
try {
+ bool warned = false;
DBClientConnection conn( true );
conn._logLevel = logger::LogSeverity::Debug(1);
string errmsg;
@@ -260,6 +267,10 @@ namespace mongo {
state->error = errorStream;
state->lastUpdate = time(0);
}
+ if ( !warned && out["storageEngine"].type() ) {
+ toolError() << "warning: detected a 3.0 mongod, some columns not applicable" << endl;
+ warned = true;
+ }
if ( out["shardCursorType"].type() == Object ||
out["process"].str() == "mongos" ) {
diff --git a/src/mongo/tools/stat_util.cpp b/src/mongo/tools/stat_util.cpp
index 7117d7ce511..d8d7c51e74b 100644
--- a/src/mongo/tools/stat_util.cpp
+++ b/src/mongo/tools/stat_util.cpp
@@ -331,9 +331,11 @@ namespace mongo {
NamespaceInfo& s = stats[e.fieldName()];
s.ns = e.fieldName();
- BSONObj temp = e.Obj()["timeLockedMicros"].Obj();
- s.read = ( temp["r"].numberLong() + temp["R"].numberLong() ) / 1000;
- s.write = ( temp["w"].numberLong() + temp["W"].numberLong() ) / 1000;
+ if ( e.Obj()["timeLockedMicros"].isABSONObj() ){
+ BSONObj temp = e.Obj()["timeLockedMicros"].Obj();
+ s.read = ( temp["r"].numberLong() + temp["R"].numberLong() ) / 1000;
+ s.write = ( temp["w"].numberLong() + temp["W"].numberLong() ) / 1000;
+ }
}
return stats;