diff options
Diffstat (limited to 'src/mongo/shell/utils.js')
| -rw-r--r-- | src/mongo/shell/utils.js | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js index e1e09a83a7b..ebfa03f7268 100644 --- a/src/mongo/shell/utils.js +++ b/src/mongo/shell/utils.js @@ -29,13 +29,6 @@ function _getErrorWithCode(codeOrObj, message) { if (codeOrObj.hasOwnProperty("writeErrors")) { e.writeErrors = codeOrObj.writeErrors; - } else if ((codeOrObj instanceof BulkWriteResult || codeOrObj instanceof BulkWriteError) && - codeOrObj.hasWriteErrors()) { - e.writeErrors = codeOrObj.getWriteErrors(); - } - - if (codeOrObj instanceof WriteResult && codeOrObj.hasWriteError()) { - e.writeErrors = [codeOrObj.getWriteError()]; } if (codeOrObj.hasOwnProperty("errorLabels")) { @@ -92,11 +85,7 @@ function isNetworkError(errorOrResponse) { "error doing query", "socket exception", "SocketException", - "HostNotFound", - "HostUnreachable", - "NetworkTimeout", - "ConnectionPoolExpired", - "ConnectionError" + "HostNotFound" ]; // Then check if it's an Error, if so see if any of the known network error strings appear @@ -1141,6 +1130,52 @@ shellHelper.show = function(what) { } } + if (what == "freeMonitoring") { + var dbDeclared, ex; + try { + // !!db essentially casts db to a boolean + // Will throw a reference exception if db hasn't been declared. + dbDeclared = !!db; + } catch (ex) { + dbDeclared = false; + } + + if (dbDeclared) { + const freemonStatus = db.adminCommand({getFreeMonitoringStatus: 1}); + + if (freemonStatus.ok) { + if (freemonStatus.state == 'enabled' && + freemonStatus.hasOwnProperty('userReminder')) { + print("---"); + print(freemonStatus.userReminder); + print("---"); + } else if (freemonStatus.state === 'undecided') { + print( + "---\n" + messageIndent + + "Enable MongoDB's free cloud-based monitoring service, which will then receive and display\n" + + messageIndent + + "metrics about your deployment (disk utilization, CPU, operation statistics, etc).\n" + + "\n" + messageIndent + + "The monitoring data will be available on a MongoDB website with a unique URL accessible to you\n" + + messageIndent + + "and anyone you share the URL with. MongoDB may use this information to make product\n" + + messageIndent + + "improvements and to suggest MongoDB products and deployment options to you.\n" + + "\n" + messageIndent + + "To enable free monitoring, run the following command: db.enableFreeMonitoring()\n" + + messageIndent + + "To permanently disable this reminder, run the following command: db.disableFreeMonitoring()\n" + + "---\n"); + } + } + + return ""; + } else { + print("Cannot show freeMonitoring, \"db\" is not set"); + return ""; + } + } + if (what == "nonGenuineMongoDBCheck") { let matchesKnownImposterSignature = false; |
