All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  update();
16 }
17 
18 
19 /*
20  * Update system performance values from /proc/self/stat virtaul file.
21  */
23  FILE* file = fopen("/proc/self/stat", "r");
24  int par = fscanf(file,
25  "%d %s %c %d %d"
26  "%d %d %d %lu %lu"
27  "%lu %lu %lu %lu %lu"
28  "%ld %ld %ld %ld %ld"
29  "%ld %lu %lu %ld %lu"
30  "%lu %lu %lu %lu %lu"
31  "%lu %lu %lu %lu %lu"
32  "%lu %lu %d %d",
33  &pid, comm, &state, &ppid, &pgrp,
34  &session, &tty_nr, &tpgid, &flags, &minflt,
35  &cminflt, &majflt, &cmajflt, &utime, &stime,
41  fclose(file);
42 
43  if (par != 39) return -1;
44 
45  struct timeval tv;
46  gettimeofday(&tv, nullptr);
47  time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
48 
49  return pid;
50 }
long unsigned sigingore
Definition: SysProcStat.h:17
long unsigned stime
Definition: SysProcStat.h:17
long unsigned startcode
Definition: SysProcStat.h:17
long unsigned sigcatch
Definition: SysProcStat.h:17
long unsigned blocked
Definition: SysProcStat.h:17
long unsigned cminflt
Definition: SysProcStat.h:17
long unsigned nswap
Definition: SysProcStat.h:17
long unsigned majflt
Definition: SysProcStat.h:17
long unsigned minflt
Definition: SysProcStat.h:17
long int itrealvalue
Definition: SysProcStat.h:20
long unsigned kstkeip
Definition: SysProcStat.h:17
long unsigned wchan
Definition: SysProcStat.h:17
long unsigned vsize
Definition: SysProcStat.h:17
virtual int update()
Definition: SysProcStat.cpp:22
long unsigned cnswap
Definition: SysProcStat.h:17
long unsigned cmajflt
Definition: SysProcStat.h:17
long unsigned signal
Definition: SysProcStat.h:17
long unsigned utime
Definition: SysProcStat.h:17
long unsigned kstkesp
Definition: SysProcStat.h:17
long unsigned startstack
Definition: SysProcStat.h:17
long unsigned rlim
Definition: SysProcStat.h:17
long unsigned flags
Definition: SysProcStat.h:17
Helper functions to set/get the application return code.
Definition: __init__.py:1
long unsigned startime
Definition: SysProcStat.h:17
long int num_threads
Definition: SysProcStat.h:20
long unsigned endcode
Definition: SysProcStat.h:17