CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
edm::service::ProcInfoFetcher Class Reference

#include <ProcInfoFetcher.h>

Public Member Functions

ProcInfo fetch () const
 
ProcInfoFetcheroperator= (ProcInfoFetcher const &)=delete
 
 ProcInfoFetcher ()
 
 ProcInfoFetcher (ProcInfoFetcher const &)=delete
 
 ~ProcInfoFetcher ()
 

Private Attributes

char buf_ [500]
 
int fd_
 
double pg_size_
 

Detailed Description

Definition at line 45 of file ProcInfoFetcher.h.

Constructor & Destructor Documentation

ProcInfoFetcher::ProcInfoFetcher ( )

Definition at line 165 of file ProcInfoFetcher.cc.

References edm::errors::Configuration, edm::hlt::Exception, and fd_.

165  :
166  pg_size_(sysconf(_SC_PAGESIZE)) {
167 #ifdef __linux__
168  std::ostringstream ost;
169  ost << "/proc/" << getpid() << "/stat";
170 
171  if((fd_ = open(ost.str().c_str(), O_RDONLY)) < 0) {
173  << "Failed to open " << ost.str() << std::endl;
174  }
175 #endif
176  }
ProcInfoFetcher::~ProcInfoFetcher ( )

Definition at line 177 of file ProcInfoFetcher.cc.

References fd_.

177  {
178 #ifdef LINUX
179  close(fd_);
180 #endif
181  }
edm::service::ProcInfoFetcher::ProcInfoFetcher ( ProcInfoFetcher const &  )
delete

Member Function Documentation

ProcInfo ProcInfoFetcher::fetch ( ) const

Definition at line 182 of file ProcInfoFetcher.cc.

References buf_, fd_, pg_size_, SiPixelLorentzAngle_cfi::read, run_regression::ret, edm::service::ProcInfo::rss, and edm::service::ProcInfo::vsize.

Referenced by edm::service::ResourceEnforcer::check(), and edm::service::SimpleMemoryCheck::fetch().

182  {
183  ProcInfo ret;
184 
185 #ifdef __linux__
186  double pr_size = 0.0, pr_rssize = 0.0;
187 
188  linux_proc pinfo;
189  int cnt;
190 
191  lseek(fd_, 0, SEEK_SET);
192 
193  if((cnt = read(fd_, buf_, sizeof(buf_) - 1)) < 0) {
194  perror("Read of Proc file failed:");
195  return ProcInfo();
196  }
197 
198  if(cnt > 0) {
199  buf_[cnt] = '\0';
200 
201 
202  try {
203  Fetcher fetcher(buf_);
204  fetcher >> pinfo.pid
205  >> pinfo.comm
206  >> pinfo.state
207  >> pinfo.ppid
208  >> pinfo.pgrp
209  >> pinfo.session
210  >> pinfo.tty
211  >> pinfo.tpgid
212  >> pinfo.flags
213  >> pinfo.minflt
214  >> pinfo.cminflt
215  >> pinfo.majflt
216  >> pinfo.cmajflt
217  >> pinfo.utime
218  >> pinfo.stime
219  >> pinfo.cutime
220  >> pinfo.cstime
221  >> pinfo.priority
222  >> pinfo.nice
223  >> pinfo.num_threads
224  >> pinfo.itrealvalue
225  >> pinfo.starttime
226  >> pinfo.vsize
227  >> pinfo.rss
228  >> pinfo.rlim
229  >> pinfo.startcode
230  >> pinfo.endcode
231  >> pinfo.startstack
232  >> pinfo.kstkesp
233  >> pinfo.kstkeip
234  >> pinfo.signal
235  >> pinfo.blocked
236  >> pinfo.sigignore
237  >> pinfo.sigcatch
238  >> pinfo.wchan;
239  } catch (boost::bad_lexical_cast& iE) {
240  LogWarning("ProcInfoFetcher")<<"Parsing of Prof file failed:"<<iE.what()<<std::endl;
241  return ProcInfo();
242  }
243 
244  // resident set size in pages
245  pr_size = (double)pinfo.vsize;
246  pr_rssize = (double)pinfo.rss;
247 
248  ret.vsize = pr_size / (1024.0*1024.0);
249  ret.rss = (pr_rssize * pg_size_) / (1024.0*1024.0);
250  }
251 #else
252  ret.vsize = 0;
253  ret.rss = 0;
254 #endif
255  return ret;
256  }
ProcInfoFetcher& edm::service::ProcInfoFetcher::operator= ( ProcInfoFetcher const &  )
delete

Member Data Documentation

char edm::service::ProcInfoFetcher::buf_[500]
mutableprivate

Definition at line 56 of file ProcInfoFetcher.h.

Referenced by fetch().

int edm::service::ProcInfoFetcher::fd_
private

Definition at line 55 of file ProcInfoFetcher.h.

Referenced by fetch(), ProcInfoFetcher(), and ~ProcInfoFetcher().

double edm::service::ProcInfoFetcher::pg_size_
private

Definition at line 54 of file ProcInfoFetcher.h.

Referenced by fetch().