Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1756

hostname function is not available

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      OS:
      node.js / npm versions:
      Additional info:
    • Developer Tools

      Problem Statement/Rationale

      What is going wrong? What action would you like the Engineering team to take?

      Please be sure to attach relevant logs with any sensitive data redacted.

      How to retrieve logs for: Compass; Shell

      In the legacy mongo, there was a function called `hostname` that would give you the current machine hostname. This is actually really useful for setting up replica sets or getting specific machine metadata.

      As a workaround, we can use

      require('os').hostname() 

      Steps to Reproduce

      How could an engineer replicate the issue you’re reporting?

      Call the function `hostname()` in any mongosh session.

      Expected Results

      What do you expect to happen?

      To return the hostname of the current machine where mongosh is running.

      Actual Results

      What do you observe is happening?

      Additional Notes

      Slack thread: https://mongodb.slack.com/archives/CUHC9R8J0/p1712739475434539

            Assignee:
            Unassigned Unassigned
            Reporter:
            kevin.mas@mongodb.com Kevin Mas Ruiz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: