[SERVER-4615] Add hostInfo command to show host info like distribution/server architecture, memory, etc. Created: 04/Jan/12  Updated: 26/Oct/15  Resolved: 29/Feb/12

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: None
Fix Version/s: 2.1.1

Type: Improvement Priority: Minor - P4
Reporter: Michael A. Fiedler Assignee: Ben Becker
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Any mongo* instance


Issue Links:
Related
is related to DOCS-1035 document hostInfo command Closed
Participants:

 Description   

Server should be able to determine what os/distro/platform it is running on.
To get a better picture of what is going on "under the hood", as well as be able to provide platform-specific guidance in regards to particular operating systems/distributions, we should have a method of reporting back these bits of information.
Possibly collect them via mms_agent and report them back so we can then inspect and act on the details.

Here's a few methods for collecting relevant information from the linux command line, and you can see there are differences. Possibly have a decision-making process to determine which method should be used to collect the rest?

# -----------------
# Centos System:
$ cat /proc/version
Linux version 2.6.32-220.2.1.el6.x86_64 (mockbuild@c6-x8664-build.centos.org) (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Fri Dec 23 02:21:33 CST 2011
 
$ uname -a
Linux myserver.biz 2.6.32-220.2.1.el6.x86_64 #1 SMP Fri Dec 23 02:21:33 CST 2011 x86_64 x86_64 x86_64 GNU/Linux
 
$ uname -rs
Linux 2.6.32-220.2.1.el6.x86_64
 
$ lsb_release -a
LSB Version:     :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:     CentOS
Description:     CentOS release 6.2 (Final)
Release:     6.2
Codename:     Final
 
$ cat /etc/*-release
CentOS release 6.2 (Final)
CentOS release 6.2 (Final)
CentOS release 6.2 (Final)
 
$ ll /etc/*-release
-rw-r--r--. 1 root root 27 Dec  8 22:05 /etc/centos-release
lrwxrwxrwx. 1 root root 14 Dec 23 16:21 /etc/redhat-release -> centos-release
lrwxrwxrwx. 1 root root 14 Dec 23 16:21 /etc/system-release -> centos-release
 
$ cat /etc/issue
CentOS release 6.2 (Final)
Kernel \r on an \m
 
# -----------------
# On an Amazon AMI instance (modeled after Fedora):
$ cat /proc/version
Linux version 2.6.35.14-97.44.amzn1.x86_64 (mockbuild@build-31006.build) (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) ) #1 SMP Mon Oct 24 16:03:08 UTC 2011
 
$ uname -a
Linux myserver.com 2.6.35.14-97.44.amzn1.x86_64 #1 SMP Mon Oct 24 16:03:08 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
 
$ uname -rs
Linux 2.6.35.14-97.44.amzn1.x86_64
 
$ lsb_release -a
-bash: lsb_release: command not found
 
$ cat /etc/*-release
Amazon Linux AMI release 2011.09
 
$ ll /etc/*-release
-rw-r--r-- 1 root root 33 Oct 27 21:24 /etc/system-release
 
$ cat /etc/issue
Amazon Linux AMI release 2011.09
Kernel \r on an \m
 
# -----------------
# Ubunutu Maverick 10.10:
$ cat /proc/version
Linux version 2.6.35-22-server (buildd@allspice) (gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu4) ) #33-Ubuntu SMP Sun Sep 19 20:48:58 UTC 2010
 
$ uname -a
Linux myserver.net 2.6.35-22-server #33-Ubuntu SMP Sun Sep 19 20:48:58 UTC 2010 x86_64 GNU/Linux
 
$ uname -rs
Linux 2.6.35-22-server
 
$ lsb_release -a
No LSB modules are available.
Distributor ID:     Ubuntu
Description:     Ubuntu maverick (development branch)
Release:     10.10
Codename:     maverick
 
$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu maverick (development branch)"
 
$ ll /etc/*-release
-rw-r--r-- 1 root root 125 2010-05-04 12:41 /etc/lsb-release
 
$ cat /etc/issue
Ubuntu maverick (development branch) \n \l
 
# -----------------
# On OSX 10.7.2:
$ cat /proc/version
cat: /proc/version: No such file or directory
 
$ uname -a
Darwin fledgling.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
 
$ uname -rs
Darwin 11.2.0
 
$ lsb_release -a
-bash: lsb_release: command not found
 
$ cat /etc/*-release
cat: /etc/*-release: No such file or directory
 
$ ll /etc/*-release
ls: /etc/*-release: No such file or directory
 
$ cat /etc/issue
cat: /etc/issue: No such file or directory

So it seems like on a *nix system, running a `uname` will provide whether it is Darwin vs Linux, and then other tests could be run to grab relevant information.

Things I'd care about knowing:
Distro (CentOS, RHEL, Debian, Ubuntu)
Distro Version (6.2, 5.7, 10.04, etc)
Architecture (i386 vs x64_86)
Kernel version (2.6.18, 2.6.32, etc)

Windows has a different method, using the `systeminfo` command line tool, like so:

C:\>systeminfo | findstr /C:"OS"
OS Name:                   Microsoft Windows Server 2008 R2 Enterprise
OS Version:                6.1.7600 N/A Build 7600
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Server
OS Build Type:             Multiprocessor Free
BIOS Version:              IBM -[BWE117AUS-1.05]-, 7/28/2005

This returns too much, including the BIOS, so using a better find like this: `findstr /B /C:"OS Name" /C:"OS Version"` should get the relevant information.



 Comments   
Comment by auto [ 03/Mar/12 ]

Author:

{u'login': u'tadmarshall', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}

Message: SERVER-4615 Fix memory in Windows hostInfo()

Set dwLength to the size of the MEMORYSTATUSEX struct before passing it it
GlobalMemoryStatusEx().
Branch: master
https://github.com/mongodb/mongo/commit/f1bfa9d78159f576f4dc43137f205eb82ba5a9f4

Comment by auto [ 29/Feb/12 ]

Author:

{u'login': u'vrtx', u'name': u'Ben Becker', u'email': u'benjamin.becker@gmail.com'}

Message: SERVER-4615: Added db.hostInfo() command
Branch: master
https://github.com/mongodb/mongo/commit/17e1dd2529d9622544717e635e71fd261977899f

Comment by Tad Marshall [ 25/Feb/12 ]

I think that Microsoft Windows Server 2008 R2 is a 64-bit-only OS, so if this is live data (and not a "for instance") then it is not correct. Are you reporting the memBits for the instance of mongod that is running and not the OS's native pointer size? Also, I think that some of the info you report for non-Windows versions would be great to have for Windows as well, such as CPU string, numCores, physicalCores, cpuFrequency and probably more. But this is a great feature and I look forward to it!

Comment by Scott Hernandez (Inactive) [ 07/Feb/12 ]

Would be very useful to report back swap/used and mem/free|cache

Comment by Ben Becker [ 02/Feb/12 ]

Just an incremental update: MacOS data collection is done (via sysctl). This might be more data than we want; suggestions welcome. Example from my MBA:

{
  "System" : { 
    "Architecture" : "x86_64",
    "Model" : "MacBookAir3,2",
    "MemSize" : "2147483648",
    "NumCores" : "2",
    "PhysicalCores" : "2",
    "CPUFrequency" : "1860000000",
    "CPUString" : "Intel(R) Core(TM)2 Duo CPU     L9400  @ 1.86GHz",
    "CPUFeatures" : "FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 XSAVE",
    "CPUExtraFeatures" : "SYSCALL XD EM64T LAHF",
    "PageSize" : "4096",
    "Scheduler" : "traditional" },
  "OS" : {
    "Type" : "Darwin",
    "Distro" : "Mac OS X",
    "Version" : "11.2.0",
    "VersionString" : "Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64",
    "BootTime" : "1328011482",
    "AlwaysFullSync" : "0",
    "NFSAsync" : "0" 
  } 
}

(Note: NumCores includes HT and is what is usually reported by the OS. PhysicalCores is the actual number of cores.)

Linux is almost done but needs testing across distros.

Exploratory work on Win32 platforms has been done; just need to implement and ensure version compatibility.

Comment by Eliot Horowitz (Inactive) [ 25/Jan/12 ]

And should be caches so its fast.

Comment by Eliot Horowitz (Inactive) [ 25/Jan/12 ]

Should be an API in ProcessInfo

Comment by Scott Hernandez (Inactive) [ 04/Jan/12 ]

Change to mms jira project

Generated at Thu Feb 08 03:06:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.