#include </builds/gaudi/Gaudi/GaudiAud/src/ProcStats.h>
Definition at line 38 of file ProcStats.h.
◆ ProcStats()
◆ fetch()
bool ProcStats::fetch |
( |
procInfo & | fill_me | ) |
|
Definition at line 259 of file ProcStats.cpp.
259 {
260 if ( !
m_valid ) {
return false; }
261
262 std::scoped_lock lock{
m_mutex };
263
264#if defined( __linux__ ) or defined( __APPLE__ )
265
266 auto read_proc = [&]() {
267 bool ok = true;
268 int cnt{ 0 };
269 char buf[500];
270 linux_proc pinfo;
271 m_ufd.lseek( 0, SEEK_SET );
272 if ( ( cnt =
m_ufd.read( buf,
sizeof( buf ) ) ) < 0 ) { ok =
false; }
273 if ( cnt > 0 ) {
274 buf[std::min( static_cast<std::size_t>( cnt ), sizeof( buf ) - 1 )] = '\0';
275 sscanf(
276 buf,
277
278
279 "%d %s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %llu %lu %ld %lu %lu %lu %lu "
280 "%lu %lu %lu %lu %lu %lu %lu",
287
288 const auto pr_size =
static_cast<double>( pinfo.
vsize );
289 const auto pr_rssize =
static_cast<double>( pinfo.
rss );
290 constexpr double MB = 1.0 / ( 1024 * 1024 );
291 f.vsize = pr_size *
MB;
293 if ( 0 == pinfo.
vsize ) { ok =
false; }
294 }
295 return ok;
296 };
297
298
299 if ( !read_proc() ) {
300 std::cerr << "ProcStats : -> Problems reading proc file. Will try reopening..." << std::endl;
302 if ( !read_proc() ) { return false; }
303 }
304
305#else
306 f.vsize = 0;
307 f.rss = 0;
308 return false;
309#endif
310
313
314 return true;
315}
unsigned long long starttime
◆ instance()
◆ open_ufd()
void ProcStats::open_ufd |
( |
| ) |
|
|
private |
Definition at line 244 of file ProcStats.cpp.
244 {
246#if defined( __linux__ ) or defined( __APPLE__ )
249 const auto fname = "/proc/" + std::to_string( getpid() ) + "/stat";
250 m_ufd.open( fname.c_str(), O_RDONLY );
252 std::cerr << "ProcStats : Failed to open " << fname << std::endl;
253 } else {
255 }
256#endif
257}
◆ pageSize()
auto ProcStats::pageSize |
( |
| ) |
const |
|
inlinenoexcept |
◆ m_curr
◆ m_mutex
std::mutex ProcStats::m_mutex |
|
private |
◆ m_pg_size
double ProcStats::m_pg_size { 0 } |
|
private |
◆ m_ufd
◆ m_valid
bool ProcStats::m_valid { false } |
|
private |
The documentation for this class was generated from the following files: