summaryrefslogtreecommitdiff
path: root/src/mongo/util/processinfo_linux2.cpp
diff options
context:
space:
mode:
authorApollon Oikonomopoulos <apoikos@debian.org>2016-01-14 00:10:06 +0200
committerApollon Oikonomopoulos <apollon@skroutz.gr>2016-01-14 00:10:06 +0200
commit374e1947abcd3e127a2a613aff73ecffdb9199ea (patch)
treed83973c3c9802450acd5b5e86fe0d4e8e60a3a1b /src/mongo/util/processinfo_linux2.cpp
parent65585c90b12d6523bea75a2aebaae2a2fdf9e641 (diff)
Imported Upstream version 2.6.11upstream/2.6.11
Diffstat (limited to 'src/mongo/util/processinfo_linux2.cpp')
-rw-r--r--src/mongo/util/processinfo_linux2.cpp42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/mongo/util/processinfo_linux2.cpp b/src/mongo/util/processinfo_linux2.cpp
index 6b06ff6258b..0030b246444 100644
--- a/src/mongo/util/processinfo_linux2.cpp
+++ b/src/mongo/util/processinfo_linux2.cpp
@@ -36,9 +36,9 @@ namespace mongo {
class LinuxProc {
public:
- LinuxProc( pid_t pid = getpid() ) {
+ LinuxProc( ProcessId pid ) {
char name[128];
- sprintf( name , "/proc/%d/stat" , pid );
+ sprintf( name , "/proc/%d/stat" , pid.asUInt32() );
FILE * f = fopen( name , "r");
if ( ! f ) {
@@ -59,7 +59,7 @@ namespace mongo {
"%lu " /* start_time */
"%lu "
"%ld " // rss
- "%lu %"KLF"u %"KLF"u %"KLF"u %"KLF"u %"KLF"u "
+ "%lu %" KLF "u %" KLF "u %" KLF "u %" KLF "u %" KLF "u "
/*
"%*s %*s %*s %*s "
"%"KLF"u %*lu %*lu "
@@ -276,7 +276,10 @@ namespace mongo {
catch (const std::out_of_range &e) {
// attempted to get invalid substr
}
- return; // return with lsb-relase data
+ // return with lsb-release data if we found both the name and version
+ if ( !name.empty() && !version.empty() ) {
+ return;
+ }
}
// try known flat-text file locations
@@ -295,6 +298,8 @@ namespace mongo {
paths.push_back( "/etc/sles-release" );
paths.push_back( "/etc/debian_release" );
paths.push_back( "/etc/slackware-version" );
+ paths.push_back( "/etc/centos-release" );
+ paths.push_back( "/etc/os-release" );
for ( i = paths.begin(); i != paths.end(); ++i ) {
// for each path
@@ -343,17 +348,21 @@ namespace mongo {
// trim whitespace and append 000 to replace kB.
while ( isspace( meminfo.at( lineOff ) ) ) lineOff++;
meminfo = meminfo.substr( lineOff );
+
+ unsigned long long systemMem = 0;
+ if ( mongo::parseNumberFromString( meminfo, &systemMem ).isOK() ) {
+ return systemMem * 1024; // convert from kB to bytes
+ }
+ else
+ log() << "Unable to collect system memory information" << endl;
}
- else {
- meminfo = "";
- }
- return atoll(meminfo.c_str()) * 1024; // convert from kB to bytes
+ return 0;
}
};
- ProcessInfo::ProcessInfo( pid_t pid ) : _pid( pid ) {
+ ProcessInfo::ProcessInfo( ProcessId pid ) : _pid( pid ) {
}
ProcessInfo::~ProcessInfo() {
@@ -432,8 +441,19 @@ namespace mongo {
* Determine if the process is running with (cc)NUMA
*/
bool ProcessInfo::checkNumaEnabled() {
- if ( boost::filesystem::exists( "/sys/devices/system/node/node1" ) &&
- boost::filesystem::exists( "/proc/self/numa_maps" ) ) {
+ bool hasMultipleNodes = false;
+ bool hasNumaMaps = false;
+
+ try {
+ hasMultipleNodes = boost::filesystem::exists("/sys/devices/system/node/node1");
+ hasNumaMaps = boost::filesystem::exists("/proc/self/numa_maps");
+ } catch(boost::filesystem::filesystem_error& e) {
+ log() << "WARNING: Cannot detect if NUMA interleaving is enabled. " <<
+ "Failed to probe \"" << e.path1().string() << "\": " << e.code().message();
+ return false;
+ }
+
+ if ( hasMultipleNodes && hasNumaMaps ) {
// proc is populated with numa entries
// read the second column of first line to determine numa state