Mongodb - db.hostInfo()

By Yashwant Chavan, Views 1248, Date 29-Oct-2016

In this tutorial we will learn how to get underlying system information on which mongod or mongos runs using db.hostInfo() command.

tags mongodb

MongoDB db.hostInfo()

db.hostInfo() - method returns document about underlying system information on which mongod or mongos runs. Some of the returned fields are only included on some platforms. Refer following db.hostInfo() method syntax.

db.hostInfo()

MongoDB db.hostInfo() output format

{
   "system" : {
          "currentTime" : ISODate("<timestamp>"),
          "hostname" : "<hostname>",
          "cpuAddrSize" : <number>,
          "memSizeMB" : <number>,
          "numCores" : <number>,
          "cpuArch" : "<identifier>",
          "numaEnabled" : <boolean>
   },
   "os" : {
          "type" : "<string>",
          "name" : "<string>",
          "version" : "<string>"
   },
   "extra" : {
          "versionString" : "<string>",
          "libcVersion" : "<string>",
          "kernelVersion" : "<string>",
          "cpuFrequencyMHz" : "<string>",
          "cpuFeatures" : "<string>",
          "pageSize" : <number>,
          "numPages" : <number>,
          "maxOpenFiles" : <number>
   },
   "ok" : <return>
}

MongoDB db.hostInfo() output

> db.hostInfo()
{
        "system" : {
                "currentTime" : ISODate("2016-10-29T10:35:10.995Z"),
                "hostname" : "swami-samartha",
                "cpuAddrSize" : 64,
                "memSizeMB" : 2984,
                "numCores" : 4,
                "cpuArch" : "x86_64",
                "numaEnabled" : false
        },
        "os" : {
                "type" : "Windows",
                "name" : "Microsoft Windows 7",
                "version" : "6.1 SP1 (build 7601)"
        },
        "extra" : {
                "pageSize" : NumberLong(4096)
        },
        "ok" : 1
}
>
Yashwant Chavan

Yashwant Chavan

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan@gmail.com