void ProcessInfo::SystemInfo::collectSystemInfo() { osType = "Darwin"; osName = "Mac OS X"; osVersion = getSysctlByName< string >( "kern.osrelease"); addrSize = (getSysctlByName< NumberVal >( "hw.cpu64bit_capable" ) ? 64 : 32); memSize = getSysctlByName< NumberVal >( "hw.memsize" ); numCores = getSysctlByName< NumberVal >( "hw.ncpu" ); // includes hyperthreading cores pageSize = static_cast<unsigned long long>(sysconf( _SC_PAGESIZE )); cpuArch = getSysctlByName< string >( "hw.machine" ); hasNuma = checkNumaEnabled(); BSONObjBuilder bExtra; bExtra.append( "versionString", getSysctlByName< string >( "kern.version" ) ); bExtra.append( "alwaysFullSync", static_cast< int >( getSysctlByName< NumberVal >( "vfs.generic.always_do_fullfsync" ) ) ); bExtra.append( "nfsAsync", static_cast< int >( getSysctlByName< NumberVal >( "vfs.generic.nfs.client.allow_async" ) ) ); bExtra.append( "model", getSysctlByName< string >( "hw.model" ) ); bExtra.append( "physicalCores", static_cast< int >( getSysctlByName< NumberVal >( "machdep.cpu.core_count" ) ) ); bExtra.append( "cpuFrequencyMHz", static_cast< int >( (getSysctlByName< NumberVal >( "hw.cpufrequency" ) / (1000 * 1000)) ) ); bExtra.append( "cpuString", getSysctlByName< string >( "machdep.cpu.brand_string" ) ); bExtra.append( "cpuFeatures", getSysctlByName< string >( "machdep.cpu.features" ) + string(" ") + getSysctlByName< string >( "machdep.cpu.extfeatures" ) ); bExtra.append( "pageSize", static_cast< int >( getSysctlByName< NumberVal >( "hw.pagesize" ) ) ); bExtra.append( "scheduler", getSysctlByName< string >( "kern.sched" ) ); _extraStats = bExtra.obj(); }
void ProcessInfo::SystemInfo::collectSystemInfo() { osType = "BSD"; osName = "FreeBSD"; int status = getSysctlByNameWithDefault("kern.version", string("unknown"), &osVersion); if (status != 0) log() << "Unable to collect OS Version. (errno: " << status << " msg: " << strerror(status) << ")" << endl; status = getSysctlByNameWithDefault("hw.machine_arch", string("unknown"), &cpuArch); if (status != 0) log() << "Unable to collect Machine Architecture. (errno: " << status << " msg: " << strerror(status) << ")" << endl; addrSize = cpuArch.find("64") != std::string::npos ? 64 : 32; uintptr_t numBuffer; uintptr_t defaultNum = 1; status = getSysctlByNameWithDefault("hw.physmem", defaultNum, &numBuffer); memSize = numBuffer; if (status != 0) log() << "Unable to collect Physical Memory. (errno: " << status << " msg: " << strerror(status) << ")" << endl; status = getSysctlByNameWithDefault("hw.ncpu", defaultNum, &numBuffer); numCores = numBuffer; if (status != 0) log() << "Unable to collect Number of CPUs. (errno: " << status << " msg: " << strerror(status) << ")" << endl; pageSize = static_cast<unsigned long long>(sysconf(_SC_PAGESIZE)); hasNuma = checkNumaEnabled(); }
/** * Save a BSON obj representing the host system's details */ void ProcessInfo::SystemInfo::collectSystemInfo() { struct utsname unameData; if (uname(&unameData) == -1) { log() << "Unable to collect detailed system information: " << strerror(errno) << endl; } char buf_64[32]; char buf_native[32]; if (sysinfo(SI_ARCHITECTURE_64, buf_64, sizeof(buf_64)) != -1 && sysinfo(SI_ARCHITECTURE_NATIVE, buf_native, sizeof(buf_native)) != -1) { addrSize = mongoutils::str::equals(buf_64, buf_native) ? 64 : 32; } else { log() << "Unable to determine system architecture: " << strerror(errno) << endl; } osType = unameData.sysname; osName = mongoutils::str::ltrim(readLineFromFile("/etc/release")); osVersion = unameData.version; pageSize = static_cast<unsigned long long>(sysconf(_SC_PAGESIZE)); memSize = pageSize * static_cast<unsigned long long>(sysconf(_SC_PHYS_PAGES)); numCores = static_cast<unsigned>(sysconf(_SC_NPROCESSORS_CONF)); cpuArch = unameData.machine; hasNuma = checkNumaEnabled(); BSONObjBuilder bExtra; bExtra.append("kernelVersion", unameData.release); bExtra.append("pageSize", static_cast<long long>(pageSize)); bExtra.append("numPages", static_cast<int>(sysconf(_SC_PHYS_PAGES))); bExtra.append("maxOpenFiles", static_cast<int>(sysconf(_SC_OPEN_MAX))); _extraStats = bExtra.obj(); }
/** * Save a BSON obj representing the host system's details */ void ProcessInfo::SystemInfo::collectSystemInfo() { struct utsname unameData; if (uname(&unameData) == -1) { log() << "Unable to collect detailed system information: " << strerror(errno); } char buf_64[32]; char buf_native[32]; if (sysinfo(SI_ARCHITECTURE_64, buf_64, sizeof(buf_64)) != -1 && sysinfo(SI_ARCHITECTURE_NATIVE, buf_native, sizeof(buf_native)) != -1) { addrSize = str::equals(buf_64, buf_native) ? 64 : 32; } else { log() << "Unable to determine system architecture: " << strerror(errno); } osType = unameData.sysname; osName = str::ltrim(readLineFromFile("/etc/release")); osVersion = unameData.version; pageSize = static_cast<unsigned long long>(sysconf(_SC_PAGESIZE)); memSize = pageSize * static_cast<unsigned long long>(sysconf(_SC_PHYS_PAGES)); memLimit = memSize; numCores = static_cast<unsigned>(sysconf(_SC_NPROCESSORS_CONF)); cpuArch = unameData.machine; hasNuma = checkNumaEnabled(); // We prefer FSync over msync, when: // 1. Pre-Oracle Solaris 11.2 releases // 2. Illumos kernel releases (which is all non Oracle Solaris releases) preferMsyncOverFSync = false; if (str::startsWith(osName, "Oracle Solaris")) { std::vector<std::string> versionComponents; str::splitStringDelim(osVersion, &versionComponents, '.'); if (versionComponents.size() > 1) { unsigned majorInt, minorInt; Status majorStatus = parseNumberFromString<unsigned>(versionComponents[0], &majorInt); Status minorStatus = parseNumberFromString<unsigned>(versionComponents[1], &minorInt); if (!majorStatus.isOK() || !minorStatus.isOK()) { warning() << "Could not parse OS version numbers from uname: " << osVersion; } else if ((majorInt == 11 && minorInt >= 2) || majorInt > 11) { preferMsyncOverFSync = true; } } else { warning() << "Could not parse OS version string from uname: " << osVersion; } } BSONObjBuilder bExtra; bExtra.append("kernelVersion", unameData.release); bExtra.append("pageSize", static_cast<long long>(pageSize)); bExtra.append("numPages", static_cast<int>(sysconf(_SC_PHYS_PAGES))); bExtra.append("maxOpenFiles", static_cast<int>(sysconf(_SC_OPEN_MAX))); _extraStats = bExtra.obj(); }
/** * Save a BSON obj representing the host system's details */ void ProcessInfo::SystemInfo::collectSystemInfo() { utsname unameData; string distroName, distroVersion; string cpuFreq, cpuFeatures; int cpuCount; string verSig = LinuxSysHelper::readLineFromFile( "/proc/version_signature" ); LinuxSysHelper::getCpuInfo(cpuCount, cpuFreq, cpuFeatures); LinuxSysHelper::getLinuxDistro( distroName, distroVersion ); if ( uname( &unameData ) == -1 ) { log() << "Unable to collect detailed system information: " << strerror( errno ) << endl; } osType = "Linux"; osName = distroName; osVersion = distroVersion; memSize = LinuxSysHelper::getSystemMemorySize(); addrSize = (string( unameData.machine ).find( "x86_64" ) != string::npos ? 64 : 32); numCores = cpuCount; pageSize = static_cast<unsigned long long>(sysconf( _SC_PAGESIZE )); cpuArch = unameData.machine; hasNuma = checkNumaEnabled(); BSONObjBuilder bExtra; bExtra.append( "versionString", LinuxSysHelper::readLineFromFile( "/proc/version" ) ); #ifdef __UCLIBC__ stringstream ss; ss << "uClibc-" << __UCLIBC_MAJOR__ << "." << __UCLIBC_MINOR__ << "." << __UCLIBC_SUBLEVEL__; bExtra.append( "libcVersion", ss.str() ); #else bExtra.append( "libcVersion", gnu_get_libc_version() ); #endif if (!verSig.empty()) // optional bExtra.append( "versionSignature", verSig ); bExtra.append( "kernelVersion", unameData.release ); bExtra.append( "cpuFrequencyMHz", cpuFreq); bExtra.append( "cpuFeatures", cpuFeatures); bExtra.append( "pageSize", static_cast<long long>(pageSize) ); bExtra.append( "numPages", static_cast< int >(sysconf( _SC_PHYS_PAGES ) ) ); bExtra.append( "maxOpenFiles", static_cast< int >(sysconf( _SC_OPEN_MAX ) ) ); _extraStats = bExtra.obj(); }
void ProcessInfo::SystemInfo::collectSystemInfo() { osType = "BSD"; osName = "OpenBSD"; int mib[2]; mib[0] = CTL_KERN; mib[1] = KERN_VERSION; int status = getSysctlByIDWithDefault(mib, 2, string("unknown"), &osVersion); if (status != 0) log() << "Unable to collect OS Version. (errno: " << status << " msg: " << strerror(status) << ")" << endl; mib[0] = CTL_HW; mib[1] = HW_MACHINE; status = getSysctlByIDWithDefault(mib, 2, string("unknown"), &cpuArch); if (status != 0) log() << "Unable to collect Machine Architecture. (errno: " << status << " msg: " << strerror(status) << ")" << endl; addrSize = cpuArch.find("64") != std::string::npos ? 64 : 32; uintptr_t numBuffer; uintptr_t defaultNum = 1; mib[0] = CTL_HW; mib[1] = HW_PHYSMEM; status = getSysctlByIDWithDefault(mib, 2, defaultNum, &numBuffer); memSize = numBuffer; if (status != 0) log() << "Unable to collect Physical Memory. (errno: " << status << " msg: " << strerror(status) << ")" << endl; mib[0] = CTL_HW; mib[1] = HW_NCPU; status = getSysctlByIDWithDefault(mib, 2, defaultNum, &numBuffer); numCores = numBuffer; if (status != 0) log() << "Unable to collect Number of CPUs. (errno: " << status << " msg: " << strerror(status) << ")" << endl; pageSize = static_cast<unsigned long long>(sysconf(_SC_PAGESIZE)); hasNuma = checkNumaEnabled(); }
void ProcessInfo::SystemInfo::collectSystemInfo() { BSONObjBuilder bExtra; stringstream verstr; OSVERSIONINFOEX osvi; // os version MEMORYSTATUSEX mse; // memory stats SYSTEM_INFO ntsysinfo; //system stats // get basic processor properties GetNativeSystemInfo( &ntsysinfo ); addrSize = (ntsysinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? 64 : 32); numCores = ntsysinfo.dwNumberOfProcessors; pageSize = static_cast<unsigned long long>(ntsysinfo.dwPageSize); bExtra.append("pageSize", static_cast<long long>(pageSize)); // get memory info mse.dwLength = sizeof( mse ); if ( GlobalMemoryStatusEx( &mse ) ) { memSize = mse.ullTotalPhys; } // get OS version info ZeroMemory( &osvi, sizeof( osvi ) ); osvi.dwOSVersionInfoSize = sizeof( osvi ); if ( GetVersionEx( (OSVERSIONINFO*)&osvi ) ) { verstr << osvi.dwMajorVersion << "." << osvi.dwMinorVersion; if ( osvi.wServicePackMajor ) verstr << " SP" << osvi.wServicePackMajor; verstr << " (build " << osvi.dwBuildNumber << ")"; osName = "Microsoft "; switch ( osvi.dwMajorVersion ) { case 6: switch ( osvi.dwMinorVersion ) { case 3: if ( osvi.wProductType == VER_NT_WORKSTATION ) osName += "Windows 8.1"; else osName += "Windows Server 2012 R2"; break; case 2: if ( osvi.wProductType == VER_NT_WORKSTATION ) osName += "Windows 8"; else osName += "Windows Server 2012"; break; case 1: if ( osvi.wProductType == VER_NT_WORKSTATION ) osName += "Windows 7"; else osName += "Windows Server 2008 R2"; break; case 0: if ( osvi.wProductType == VER_NT_WORKSTATION ) osName += "Windows Vista"; else osName += "Windows Server 2008"; break; default: osName += "Windows NT version "; osName += verstr.str(); break; } break; case 5: switch ( osvi.dwMinorVersion ) { case 2: osName += "Windows Server 2003"; break; case 1: osName += "Windows XP"; break; case 0: if ( osvi.wProductType == VER_NT_WORKSTATION ) osName += "Windows 2000 Professional"; else osName += "Windows 2000 Server"; break; default: osName += "Windows NT version "; osName += verstr.str(); break; } break; } } else { // unable to get any version data osName += "Windows NT"; } if ( ntsysinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ) { cpuArch = "x86_64"; } else if ( ntsysinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL ) { cpuArch = "x86"; } else if ( ntsysinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ) { cpuArch = "ia64"; } else { cpuArch = "unknown"; } osType = "Windows"; osVersion = verstr.str(); hasNuma = checkNumaEnabled(); _extraStats = bExtra.obj(); if (psapiGlobal == NULL) { psapiGlobal = new PsApiInit(); } }
void ProcessInfo::SystemInfo::collectSystemInfo() { BSONObjBuilder bExtra; stringstream verstr; OSVERSIONINFOEX osvi; // os version MEMORYSTATUSEX mse; // memory stats SYSTEM_INFO ntsysinfo; // system stats // get basic processor properties GetNativeSystemInfo(&ntsysinfo); addrSize = (ntsysinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? 64 : 32); numCores = ntsysinfo.dwNumberOfProcessors; pageSize = static_cast<unsigned long long>(ntsysinfo.dwPageSize); bExtra.append("pageSize", static_cast<long long>(pageSize)); // get memory info mse.dwLength = sizeof(mse); if (GlobalMemoryStatusEx(&mse)) { memSize = mse.ullTotalPhys; } // get OS version info ZeroMemory(&osvi, sizeof(osvi)); osvi.dwOSVersionInfoSize = sizeof(osvi); if (GetVersionEx((OSVERSIONINFO*)&osvi)) { verstr << osvi.dwMajorVersion << "." << osvi.dwMinorVersion; if (osvi.wServicePackMajor) verstr << " SP" << osvi.wServicePackMajor; verstr << " (build " << osvi.dwBuildNumber << ")"; osName = "Microsoft "; switch (osvi.dwMajorVersion) { case 6: switch (osvi.dwMinorVersion) { case 3: if (osvi.wProductType == VER_NT_WORKSTATION) osName += "Windows 8.1"; else osName += "Windows Server 2012 R2"; break; case 2: if (osvi.wProductType == VER_NT_WORKSTATION) osName += "Windows 8"; else osName += "Windows Server 2012"; break; case 1: if (osvi.wProductType == VER_NT_WORKSTATION) osName += "Windows 7"; else osName += "Windows Server 2008 R2"; // Windows 6.1 is either Windows 7 or Windows 2008 R2. There is no SP2 for // either of these two operating systems, but the check will hold if one // were released. This code assumes that SP2 will include fix for // http://support.microsoft.com/kb/2731284. // if ((osvi.wServicePackMajor >= 0) && (osvi.wServicePackMajor < 2)) { if (isKB2731284OrLaterUpdateInstalled()) { log() << "Hotfix KB2731284 or later update is installed, no need " "to zero-out data files"; fileZeroNeeded = false; } else { log() << "Hotfix KB2731284 or later update is not installed, will " "zero-out data files"; fileZeroNeeded = true; } } break; case 0: if (osvi.wProductType == VER_NT_WORKSTATION) osName += "Windows Vista"; else osName += "Windows Server 2008"; break; default: osName += "Windows NT version "; osName += verstr.str(); break; } break; case 5: switch (osvi.dwMinorVersion) { case 2: osName += "Windows Server 2003"; break; case 1: osName += "Windows XP"; break; case 0: if (osvi.wProductType == VER_NT_WORKSTATION) osName += "Windows 2000 Professional"; else osName += "Windows 2000 Server"; break; default: osName += "Windows NT version "; osName += verstr.str(); break; } break; } } else { // unable to get any version data osName += "Windows NT"; } if (ntsysinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { cpuArch = "x86_64"; } else if (ntsysinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) { cpuArch = "x86"; } else if (ntsysinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) { cpuArch = "ia64"; } else { cpuArch = "unknown"; } osType = "Windows"; osVersion = verstr.str(); hasNuma = checkNumaEnabled(); _extraStats = bExtra.obj(); if (psapiGlobal == NULL) { psapiGlobal = new PsApiInit(); } }