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 175 of file ProcInfoFetcher.cc.

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

175  :
176  pg_size_(sysconf(_SC_PAGESIZE)) {
177 #ifdef __linux__
178  std::ostringstream ost;
179  ost << "/proc/" << getpid() << "/stat";
180 
181  if((fd_ = open(ost.str().c_str(), O_RDONLY)) < 0) {
183  << "Failed to open " << ost.str() << std::endl;
184  }
185 #endif
186  }
ProcInfoFetcher::~ProcInfoFetcher ( )

Definition at line 187 of file ProcInfoFetcher.cc.

References fd_.

187  {
188 #ifdef LINUX
189  close(fd_);
190 #endif
191  }
edm::service::ProcInfoFetcher::ProcInfoFetcher ( ProcInfoFetcher const &  )
delete

Member Function Documentation

ProcInfo ProcInfoFetcher::fetch ( ) const

Definition at line 192 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().

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