The Gaudi Framework  v30r3 (a5ef0a68)
SysProcStat.cpp
Go to the documentation of this file.
1 /*
2  * SysProcStat.cpp
3  *
4  * Created on: Jul 6, 2012
5  * Author: Ivan Valencik
6  */
7 
8 #include "RootCnv/SysProcStat.h"
9 
10 #include <cstdio>
11 #include <sys/time.h>
12 using namespace Gaudi;
13 
15 
16 /*
17  * Update system performance values from /proc/self/stat virtaul file.
18  */
20 {
21  FILE* file = fopen( "/proc/self/stat", "r" );
22  int par = fscanf( file, "%d %s %c %d %d"
23  "%d %d %d %lu %lu"
24  "%lu %lu %lu %lu %lu"
25  "%ld %ld %ld %ld %ld"
26  "%ld %lu %lu %ld %lu"
27  "%lu %lu %lu %lu %lu"
28  "%lu %lu %lu %lu %lu"
29  "%lu %lu %d %d",
34  fclose( file );
35 
36  if ( par != 39 ) return -1;
37 
38  struct timeval tv;
39  gettimeofday( &tv, nullptr );
40  time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
41 
42  return pid;
43 }
long unsigned sigingore
Definition: SysProcStat.h:18
long unsigned stime
Definition: SysProcStat.h:18
long unsigned startcode
Definition: SysProcStat.h:18
long unsigned sigcatch
Definition: SysProcStat.h:18
long unsigned blocked
Definition: SysProcStat.h:18
long unsigned cminflt
Definition: SysProcStat.h:18
long unsigned nswap
Definition: SysProcStat.h:18
long unsigned majflt
Definition: SysProcStat.h:18
long unsigned minflt
Definition: SysProcStat.h:18
long int itrealvalue
Definition: SysProcStat.h:20
long unsigned kstkeip
Definition: SysProcStat.h:18
long unsigned wchan
Definition: SysProcStat.h:18
long unsigned vsize
Definition: SysProcStat.h:18
virtual int update()
Definition: SysProcStat.cpp:19
long unsigned cnswap
Definition: SysProcStat.h:18
long unsigned cmajflt
Definition: SysProcStat.h:18
long unsigned signal
Definition: SysProcStat.h:18
long unsigned utime
Definition: SysProcStat.h:18
long unsigned kstkesp
Definition: SysProcStat.h:18
long unsigned startstack
Definition: SysProcStat.h:18
long unsigned rlim
Definition: SysProcStat.h:18
long unsigned flags
Definition: SysProcStat.h:18
Helper functions to set/get the application return code.
Definition: __init__.py:1
long unsigned startime
Definition: SysProcStat.h:18
long int num_threads
Definition: SysProcStat.h:20
long unsigned endcode
Definition: SysProcStat.h:18