Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make getMongoData.js compatible with mongosh #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

BassT
Copy link

@BassT BassT commented Sep 12, 2023

  • mongosh doesn't include the native method hostname() anymore and deprecated db.printSlaveReplicationInfo()
  • to make getMongoData.js compatible with mongosh
    • check if hostname() method exists, if not, use os.hostname() as hostname of host running mongosh
    • check if db.printSlaveReplicationInfo is deprecated and use db.printSecondaryReplicationInfo instead

* 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"
Copy link

@orca-security-us orca-security-us bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

@@ -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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of returning N/A mongosh supports os.hostname()

@@ -580,7 +580,7 @@ if (! _printJSON) {
print("getMongoData.js version " + _version);
print("================================");
}
var _host = hostname();
var _host = typeof hostname !== "undefined" ? hostname() : "N/A";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here we should use os.hostname()

* Use os.hostname instead of "N/A" for shell hostname
* Use db.printSecondaryReplicationInfo() instead of db.printSlaveReplicationInfo() if printSlaveReplicationInfo is deprecated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants