summaryrefslogtreecommitdiff
path: root/overlay/cpu-top.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-27 23:51:32 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-27 23:52:03 +0100
commita18023f67864841fbeee6c93e9c504768e652281 (patch)
treec7e2c58babb400f81cfb3f71123739421abdded3 /overlay/cpu-top.c
parent11567e318e6a05936bab135e6ed90726583ab031 (diff)
overlay: Add number of running processes to CPU display
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/cpu-top.c')
-rw-r--r--overlay/cpu-top.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/overlay/cpu-top.c b/overlay/cpu-top.c
index c134d409..13ae70d4 100644
--- a/overlay/cpu-top.c
+++ b/overlay/cpu-top.c
@@ -23,6 +23,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
@@ -44,7 +45,7 @@ int cpu_top_update(struct cpu_top *cpu)
struct cpu_stat *s = &cpu->stat[cpu->count++&1];
struct cpu_stat *d = &cpu->stat[cpu->count&1];
uint64_t d_total, d_idle;
- char buf[4096];
+ char buf[4096], *b;
int fd, len = -1;
fd = open("/proc/stat", 0);
@@ -66,6 +67,10 @@ int cpu_top_update(struct cpu_top *cpu)
&s->user, &s->nice, &s->sys, &s->idle);
#endif
+ b = strstr(buf, "procs_running");
+ if (b)
+ cpu->nr_running = atoi(b+sizeof("procs_running")) - 1;
+
s->total = s->user + s->nice + s->sys + s->idle;
if (cpu->count == 1)
return EAGAIN;