| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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
14 SysProcStat::SysProcStat() {
15 update();
16 }
17
18 SysProcStat::~SysProcStat() { }
19
20 /*
21 * Update system performance values from /proc/self/stat virtaul file.
22 */
23 int SysProcStat::update() {
24 FILE* file = fopen("/proc/self/stat", "r");
25 int par = fscanf(file,
26 "%d %s %c %d %d"
27 "%d %d %d %lu %lu"
28 "%lu %lu %lu %lu %lu"
29 "%ld %ld %ld %ld %ld"
30 "%ld %lu %lu %ld %lu"
31 "%lu %lu %lu %lu %lu"
32 "%lu %lu %lu %lu %lu"
33 "%lu %lu %d %d",
34 &pid, comm, &state, &ppid, &pgrp,
35 &session, &tty_nr, &tpgid, &flags, &minflt,
36 &cminflt, &majflt, &cmajflt, &utime, &stime,
37 &cutime, &cstime, &priority, &nice, &num_threads,
38 &itrealvalue, &startime, &vsize, &rss, &rlim,
39 &startcode, &endcode, &startstack, &kstkesp, &kstkeip,
40 &signal, &blocked, &sigingore, &sigcatch, &wchan,
41 &nswap, &cnswap, &exit_signal, &processor);
42 fclose(file);
43
44 if (par != 39)
45 return -1;
46
47 struct timeval tv;
48 gettimeofday(&tv, NULL);
49 time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
50
51 return pid;
52 }