26 #include <boost/lexical_cast.hpp> 57 unsigned long cminflt;
59 unsigned long cmajflt;
72 unsigned long startcode;
73 unsigned long endcode;
74 unsigned long startstack;
75 unsigned long kstkesp;
76 unsigned long kstkeip;
78 unsigned long blocked;
79 unsigned long sigignore;
80 unsigned long sigcatch;
88 friend Fetcher&
operator>>(Fetcher&,
unsigned int&);
89 friend Fetcher&
operator>>(Fetcher&,
unsigned long&);
90 friend Fetcher&
operator>>(Fetcher&,
unsigned long long&);
94 explicit Fetcher(
char* buffer) :
97 delims_(
" \t\n\f\v\r") {
101 const char*
t = getItem();
103 return boost::lexical_cast<
int>(
t);
106 const char*
t = getItem();
108 return boost::lexical_cast<
long>(
t);
110 unsigned int getUInt() {
111 const char*
t = getItem();
113 return boost::lexical_cast<
unsigned int>(
t);
115 unsigned long getULong() {
116 const char*
t = getItem();
118 return boost::lexical_cast<
unsigned long>(
t);
120 unsigned long long getULongLong() {
121 const char*
t = getItem();
123 return boost::lexical_cast<
unsigned long long>(
t);
132 char* item = strtok_r(buffer_, delims_, &
save());
143 char const*
const delims_;
146 Fetcher&
operator>>(Fetcher& iFetch,
int& oValue) {
147 oValue = iFetch.getInt();
150 Fetcher&
operator>>(Fetcher& iFetch,
long& oValue) {
151 oValue = iFetch.getLong();
154 Fetcher&
operator>>(Fetcher& iFetch,
unsigned int& oValue) {
155 oValue = iFetch.getUInt();
158 Fetcher&
operator>>(Fetcher& iFetch,
unsigned long& oValue) {
159 oValue = iFetch.getULong();
162 Fetcher&
operator>>(Fetcher& iFetch,
unsigned long long& oValue) {
163 oValue = iFetch.getULongLong();
166 Fetcher&
operator>>(Fetcher& iFetch,
char& oValue) {
167 oValue = iFetch.getChar();
171 oValue = iFetch.getString();
179 ProcInfoFetcher::ProcInfoFetcher():
180 pg_size_(sysconf(_SC_PAGESIZE)) {
182 std::ostringstream ost;
183 ost <<
"/proc/" << getpid() <<
"/stat";
185 if((
fd_ = open(ost.str().c_str(), O_RDONLY)) < 0) {
187 <<
"Failed to open " << ost.str() << std::endl;
200 double pr_size = 0.0, pr_rssize = 0.0;
205 lseek(
fd_, 0, SEEK_SET);
207 if((cnt = read(
fd_,
buf_,
sizeof(
buf_) - 1)) < 0) {
208 perror(
"Read of Proc file failed:");
217 Fetcher fetcher(
buf_);
253 }
catch (boost::bad_lexical_cast& iE) {
254 LogWarning(
"ProcInfoFetcher")<<
"Parsing of Prof file failed:"<<iE.what()<<std::endl;
259 pr_size = (double)pinfo.vsize;
260 pr_rssize = (
double)pinfo.rss;
262 ret.
vsize = pr_size / (1024.0*1024.0);
263 ret.
rss = (pr_rssize *
pg_size_) / (1024.0*1024.0);
std::vector< Variable::Flags > flags
int getInt(ResultSet *rset, int ipar)
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::istream & operator>>(std::istream &input, CLHEP::HepGenMatrix &matrix)