CMS 3D CMS Logo

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 41 of file ProcInfoFetcher.h.

Constructor & Destructor Documentation

◆ ProcInfoFetcher() [1/2]

ProcInfoFetcher::ProcInfoFetcher ( )

Definition at line 171 of file ProcInfoFetcher.cc.

171  : pg_size_(sysconf(_SC_PAGESIZE)) {
172 #ifdef __linux__
173  std::ostringstream ost;
174  ost << "/proc/" << getpid() << "/stat";
175 
176  if ((fd_ = open(ost.str().c_str(), O_RDONLY)) < 0) {
177  throw Exception(errors::Configuration) << "Failed to open " << ost.str() << std::endl;
178  }
179 #endif
180  }

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

◆ ~ProcInfoFetcher()

ProcInfoFetcher::~ProcInfoFetcher ( )

Definition at line 181 of file ProcInfoFetcher.cc.

181  {
182 #ifdef LINUX
183  close(fd_);
184 #endif
185  }

References fd_.

◆ ProcInfoFetcher() [2/2]

edm::service::ProcInfoFetcher::ProcInfoFetcher ( ProcInfoFetcher const &  )
delete

Member Function Documentation

◆ fetch()

ProcInfo ProcInfoFetcher::fetch ( ) const

Definition at line 186 of file ProcInfoFetcher.cc.

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

References buf_, fd_, pg_size_, readEcalDQMStatus::read, and runTheMatrix::ret.

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

◆ operator=()

ProcInfoFetcher& edm::service::ProcInfoFetcher::operator= ( ProcInfoFetcher const &  )
delete

Member Data Documentation

◆ buf_

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

Definition at line 53 of file ProcInfoFetcher.h.

Referenced by fetch().

◆ fd_

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

Definition at line 52 of file ProcInfoFetcher.h.

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

◆ pg_size_

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

Definition at line 51 of file ProcInfoFetcher.h.

Referenced by fetch().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::service::ProcInfoFetcher::pg_size_
double pg_size_
Definition: ProcInfoFetcher.h:51
edm::service::ProcInfoFetcher::fd_
int fd_
Definition: ProcInfoFetcher.h:52
readEcalDQMStatus.read
read
Definition: readEcalDQMStatus.py:38
Exception
Definition: hltDiff.cc:245
edm::service::ProcInfoFetcher::buf_
char buf_[500]
Definition: ProcInfoFetcher.h:53
edm::errors::Configuration
Definition: EDMException.h:36