@@ -15,8 +15,25 @@ static int proc_show_version(struct proc_entry *UNUSED(entry), struct proc_data
15
15
}
16
16
17
17
static int proc_show_stat (struct proc_entry * UNUSED (entry ), struct proc_data * buf ) {
18
+ int ncpus = get_cpu_count ();
18
19
struct cpu_usage usage = get_cpu_usage ();
19
- proc_printf (buf , "cpu %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 "\n" , usage .user_ticks , usage .nice_ticks , usage .system_ticks , usage .idle_ticks );
20
+ struct uptime_info uptime_info = get_uptime ();
21
+ unsigned uptime = uptime_info .uptime_ticks ;
22
+
23
+ uint64_t one_cpu_user_ticks = usage .user_ticks / ncpus ;
24
+ uint64_t one_cpu_system_ticks = usage .system_ticks / ncpus ;
25
+ uint64_t one_cpu_idle_ticks = usage .idle_ticks / ncpus ;
26
+ uint64_t one_cpu_nice_ticks = usage .nice_ticks / ncpus ;
27
+
28
+ proc_printf (buf , "cpu %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " 0 0 0 0\n" , usage .user_ticks , usage .nice_ticks , usage .system_ticks , usage .idle_ticks );
29
+ for (int i = 0 ; i < ncpus ; i ++ ) {
30
+ proc_printf (buf , "cpu%d %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " 0 0 0 0\n" , i , one_cpu_user_ticks , one_cpu_nice_ticks , one_cpu_system_ticks , one_cpu_idle_ticks );
31
+ }
32
+ proc_printf (buf , "ctxt 0\n" );
33
+ proc_printf (buf , "btime %u\n" , uptime );
34
+ proc_printf (buf , "processes %d\n" , alive_task_count );
35
+ proc_printf (buf , "procs_running %d\n" , alive_task_count - blocked_task_count );
36
+ proc_printf (buf , "procs_blocked %d\n" , blocked_task_count );
20
37
return 0 ;
21
38
}
22
39
0 commit comments