3
0

top_system_cpu.diff 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. diff -purN busybox.ori/include/libbb.h busybox/include/libbb.h
  2. --- busybox.ori/include/libbb.h 2004-03-21 14:39:35.000000000 +0100
  3. +++ busybox-1.0/include/libbb.h 2004-03-21 14:45:35.000000000 +0100
  4. @@ -447,6 +447,7 @@ typedef struct {
  5. int ppid;
  6. #ifdef FEATURE_CPU_USAGE_PERCENTAGE
  7. unsigned pcpu;
  8. + unsigned pscpu;
  9. unsigned long stime, utime;
  10. #endif
  11. char *cmd;
  12. diff -purN busybox.ori/procps/top.c busybox/procps/top.c
  13. --- busybox.ori/procps/top.c 2004-03-21 14:40:09.000000000 +0100
  14. +++ busybox-1.0/procps/top.c 2004-03-21 17:27:52.961951448 +0100
  15. @@ -289,6 +289,15 @@ static void do_stats(void)
  16. i = 999;
  17. cur->pcpu = i;
  18. + /*
  19. + * Calculate percent of system time from cpu time
  20. + */
  21. + if (systime != 0) {
  22. + cur->pscpu = 100 * total_time / systime;
  23. + } else {
  24. + cur->pscpu = 0;
  25. + }
  26. +
  27. }
  28. /*
  29. @@ -393,7 +402,7 @@ static void display_status(int count, in
  30. #ifdef FEATURE_CPU_USAGE_PERCENTAGE
  31. /* what info of the processes is shown */
  32. - printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%MEM COMMAND\e[0m\n");
  33. + printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%SCPU %%MEM COMMAND\e[0m\n");
  34. #else
  35. printf("\n\e[7m PID USER STATUS RSS PPID %%MEM COMMAND\e[0m\n");
  36. #endif
  37. @@ -410,9 +419,9 @@ static void display_status(int count, in
  38. else
  39. sprintf(rss_str_buf, "%7ld", s->rss);
  40. #ifdef FEATURE_CPU_USAGE_PERCENTAGE
  41. - printf("%5d %-8s %s %s %5d %2d.%d %2u.%u ",
  42. + printf("%5d %-8s %s %s %5d %2d.%d %2d.%d %2u.%u ",
  43. s->pid, s->user, s->state, rss_str_buf, s->ppid,
  44. - s->pcpu/10, s->pcpu%10, pmem/10, pmem%10);
  45. + s->pcpu/10, s->pcpu%10,s->pscpu/10, s->pscpu%10, pmem/10, pmem%10);
  46. #else
  47. printf("%5d %-8s %s %s %5d %2u.%u ",
  48. s->pid, s->user, s->state, rss_str_buf, s->ppid,