From c273034f41d0d5d14592f885817cd31c0a82014b Mon Sep 17 00:00:00 2001 From: Sebastian Richter Date: Tue, 12 Sep 2023 11:46:49 +0200 Subject: [PATCH 1/2] Make getMongoData.js compatible with mongosh * mongosh doesn't include the native hostname() method anymore * to make getMongoData.js compatible with mongosh check if hostname() method exists * if not, put "N/A" --- getMongoData/getMongoData.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getMongoData/getMongoData.js b/getMongoData/getMongoData.js index ab9440a..d741759 100644 --- a/getMongoData/getMongoData.js +++ b/getMongoData/getMongoData.js @@ -263,7 +263,7 @@ function printInfo(message, command, section, printCapture, commandParameters) { function printServerInfo() { section = "server_info"; printInfo('Shell version', version, section); - printInfo('Shell hostname', hostname, section); + printInfo('Shell hostname', typeof hostname !== "undefined" ? hostname : function(){return "N/A"}, section); printInfo('db', function(){return db.getName()}, section); printInfo('Server status info', function(){return db.serverStatus()}, section); printInfo('Host info', function(){return db.hostInfo()}, section); @@ -580,7 +580,7 @@ if (! _printJSON) { print("getMongoData.js version " + _version); print("================================"); } -var _host = hostname(); +var _host = typeof hostname !== "undefined" ? hostname() : "N/A"; try { printServerInfo(); From 728555d187fb57b56a40faea8a1ef58422d96ce7 Mon Sep 17 00:00:00 2001 From: Sebastian Richter Date: Thu, 14 Sep 2023 15:22:58 +0200 Subject: [PATCH 2/2] Update getMongoData.js * Use os.hostname instead of "N/A" for shell hostname * Use db.printSecondaryReplicationInfo() instead of db.printSlaveReplicationInfo() if printSlaveReplicationInfo is deprecated --- getMongoData/getMongoData.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/getMongoData/getMongoData.js b/getMongoData/getMongoData.js index d741759..f8d935a 100644 --- a/getMongoData/getMongoData.js +++ b/getMongoData/getMongoData.js @@ -263,7 +263,7 @@ function printInfo(message, command, section, printCapture, commandParameters) { function printServerInfo() { section = "server_info"; printInfo('Shell version', version, section); - printInfo('Shell hostname', typeof hostname !== "undefined" ? hostname : function(){return "N/A"}, section); + printInfo('Shell hostname', typeof hostname !== "undefined" ? hostname : os.hostname, section); printInfo('db', function(){return db.getName()}, section); printInfo('Server status info', function(){return db.serverStatus()}, section); printInfo('Host info', function(){return db.hostInfo()}, section); @@ -277,7 +277,7 @@ function printReplicaSetInfo() { printInfo('Replica set config', function(){return rs.conf()}, section); printInfo('Replica status', function(){return rs.status()}, section); printInfo('Replica info', function(){return db.getReplicationInfo()}, section); - printInfo('Replica slave info', function(){return db.printSlaveReplicationInfo()}, section, true); + printInfo('Replica slave info', db.printSlaveReplicationInfo.deprecated ? function(){return db.printSecondaryReplicationInfo()} : function(){return db.printSlaveReplicationInfo()}, section, true); } function printUserAuthInfo() { @@ -580,7 +580,7 @@ if (! _printJSON) { print("getMongoData.js version " + _version); print("================================"); } -var _host = typeof hostname !== "undefined" ? hostname() : "N/A"; +var _host = typeof hostname !== "undefined" ? hostname() : os.hostname(); try { printServerInfo();