]>
Commit | Line | Data |
---|---|---|
bd81bec6 AM |
1 | --- util-vserver-0.30.216-pre2926/src/vserver-stat.c 2010-12-02 16:30:12.000000000 +0100 |
2 | +++ util-vserver-0.30.216-pre2926.new/src/vserver-stat.c 2011-01-18 20:32:23.465389530 +0100 | |
3 | @@ -309,6 +309,7 @@ | |
4 | unsigned long long rss; | |
5 | char *endptr; | |
6 | size_t len; | |
7 | + uint64_t stime_total, utime_total; | |
8 | ||
9 | if (vc_virt_stat(xid, &vstat) == -1) { | |
10 | perror("vc_virt_stat()"); | |
11 | @@ -402,6 +403,24 @@ | |
12 | return; | |
13 | } | |
14 | ||
15 | + strcpy(filename, cgroup); | |
16 | + strcpy(filename + cgroup_len, "/cpuacct.stat"); | |
17 | + | |
18 | + if ((fd = open(filename, O_RDONLY)) == -1) { | |
19 | + perror("open(cpuacct.stat)"); | |
20 | + return; | |
21 | + } | |
22 | + if (read(fd, buf, sizeof(buf)) == -1) { | |
23 | + perror("read(cpuacct.stat)"); | |
24 | + return; | |
25 | + } | |
26 | + close(fd); | |
27 | + | |
28 | + if (sscanf(buf, "user %lu\nsystem %lu\n", &utime_total, &stime_total) != 2) { | |
29 | + perror("sscanf(cpuacct.stat)"); | |
30 | + return; | |
31 | + } | |
32 | + | |
33 | res = Vector_insert(vec, &xid, cmpData); | |
34 | res->xid = xid; | |
35 | ||
36 | @@ -409,18 +428,8 @@ | |
37 | res->VmRSS_total = rss / 4096; | |
38 | res->start_time_oldest= getUptime() - vstat.uptime/1000000; | |
39 | ||
40 | - res->utime_total = 0; | |
41 | - res->stime_total = 0; | |
42 | - // XXX: arbitrary CPU limit. | |
43 | - for (cpu = 0; cpu < 1024; cpu++) { | |
44 | - sched.cpu_id = cpu; | |
45 | - sched.bucket_id = 0; | |
46 | - if (vc_sched_info(xid, &sched) == -1) | |
47 | - break; | |
48 | - | |
49 | - res->utime_total += sched.user_msec; | |
50 | - res->stime_total += sched.sys_msec; | |
51 | - } | |
afce1e26 AM |
52 | + res->utime_total = utime_total * sysconf(_SC_CLK_TCK) /* USER_HZ */; |
53 | + res->stime_total = stime_total * sysconf(_SC_CLK_TCK) /* USER_HZ */; | |
bd81bec6 AM |
54 | } |
55 | ||
56 | res->VmSize_total += process->VmSize; | |
57 |