00001 // processinfo.h 00002 00003 /* Copyright 2009 10gen Inc. 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #pragma once 00019 00020 #include <sys/types.h> 00021 #include <string> 00022 00023 #ifndef _WIN32 00024 #include <unistd.h> 00025 #else 00026 typedef int pid_t; 00027 int getpid(); 00028 #endif 00029 00030 namespace mongo { 00031 00032 class BSONObjBuilder; 00033 00034 class ProcessInfo { 00035 public: 00036 ProcessInfo( pid_t pid = getpid() ); 00037 ~ProcessInfo(); 00038 00042 int getVirtualMemorySize(); 00043 00047 int getResidentSize(); 00048 00052 void getExtraInfo(BSONObjBuilder& info); 00053 00054 bool supported(); 00055 00056 bool blockCheckSupported(); 00057 bool blockInMemory( char * start ); 00058 00059 private: 00060 pid_t _pid; 00061 }; 00062 00063 void writePidFile( const std::string& path ); 00064 00065 void printMemInfo( const char * where ); 00066 00067 }