26 #include <boost/lexical_cast.hpp>
56 unsigned long cminflt;
58 unsigned long cmajflt;
71 unsigned long startcode;
72 unsigned long endcode;
73 unsigned long startstack;
74 unsigned long kstkesp;
75 unsigned long kstkeip;
77 unsigned long blocked;
78 unsigned long sigignore;
79 unsigned long sigcatch;
87 friend Fetcher&
operator>>(Fetcher&,
unsigned int&);
88 friend Fetcher&
operator>>(Fetcher&,
unsigned long&);
89 friend Fetcher&
operator>>(Fetcher&,
unsigned long long&);
93 explicit Fetcher(
char* buffer) :
96 delims_(
" \t\n\f\v\r") {
100 const char*
t = getItem();
102 return boost::lexical_cast<
int>(
t);
105 const char*
t = getItem();
107 return boost::lexical_cast<
long>(
t);
109 unsigned int getUInt() {
110 const char*
t = getItem();
112 return boost::lexical_cast<
unsigned int>(
t);
114 unsigned long getULong() {
115 const char*
t = getItem();
117 return boost::lexical_cast<
unsigned long>(
t);
119 unsigned long long getULongLong() {
120 const char*
t = getItem();
122 return boost::lexical_cast<
unsigned long long>(
t);
131 char* item = strtok_r(buffer_, delims_, &save_);
138 char const*
const delims_;
141 Fetcher&
operator>>(Fetcher& iFetch,
int& oValue) {
142 oValue = iFetch.getInt();
145 Fetcher&
operator>>(Fetcher& iFetch,
long& oValue) {
146 oValue = iFetch.getLong();
149 Fetcher&
operator>>(Fetcher& iFetch,
unsigned int& oValue) {
150 oValue = iFetch.getUInt();
153 Fetcher&
operator>>(Fetcher& iFetch,
unsigned long& oValue) {
154 oValue = iFetch.getULong();
157 Fetcher&
operator>>(Fetcher& iFetch,
unsigned long long& oValue) {
158 oValue = iFetch.getULongLong();
161 Fetcher&
operator>>(Fetcher& iFetch,
char& oValue) {
162 oValue = iFetch.getChar();
166 oValue = iFetch.getString();
175 pg_size_(sysconf(_SC_PAGESIZE)) {
177 std::ostringstream ost;
178 ost <<
"/proc/" << getpid() <<
"/stat";
180 if((
fd_ = open(ost.str().c_str(), O_RDONLY)) < 0) {
182 <<
"Failed to open " << ost.str() << std::endl;
195 double pr_size = 0.0, pr_rssize = 0.0;
200 lseek(
fd_, 0, SEEK_SET);
203 perror(
"Read of Proc file failed:");
212 Fetcher fetcher(
buf_);
248 }
catch (boost::bad_lexical_cast& iE) {
249 LogWarning(
"ProcInfoFetcher")<<
"Parsing of Prof file failed:"<<iE.what()<<std::endl;
254 pr_size = (double)pinfo.vsize;
255 pr_rssize = (
double)pinfo.rss;
257 ret.
vsize = pr_size / (1024.0*1024.0);
258 ret.
rss = (pr_rssize *
pg_size_) / (1024.0*1024.0);
std::vector< Variable::Flags > flags
int getInt(ResultSet *rset, int ipar)
std::istream & operator>>(std::istream &input, CLHEP::HepGenMatrix &matrix)