diff options
| author | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-09-16 12:55:29 +0000 |
|---|---|---|
| committer | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-09-16 12:55:29 +0000 |
| commit | f246dc7f57335b01e5e503d14eb4ef0eb28d2f94 (patch) | |
| tree | 1087a44db7d46fd29cc247e7071d7077e2958b5c | |
| parent | c350485b18b95954496e12161a87ee016f2bbb81 (diff) | |
| download | busybox-w32-f246dc7f57335b01e5e503d14eb4ef0eb28d2f94.tar.gz busybox-w32-f246dc7f57335b01e5e503d14eb4ef0eb28d2f94.tar.bz2 busybox-w32-f246dc7f57335b01e5e503d14eb4ef0eb28d2f94.zip | |
ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE->CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE
| -rw-r--r-- | include/libbb.h | 2 | ||||
| -rw-r--r-- | libbb/procps.c | 6 | ||||
| -rw-r--r-- | procps/Config.in | 2 | ||||
| -rw-r--r-- | procps/top.c | 32 |
4 files changed, 21 insertions, 21 deletions
diff --git a/include/libbb.h b/include/libbb.h index 71ba8feac..e767948d7 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
| @@ -445,7 +445,7 @@ typedef struct { | |||
| 445 | char state[4]; | 445 | char state[4]; |
| 446 | unsigned long rss; | 446 | unsigned long rss; |
| 447 | int ppid; | 447 | int ppid; |
| 448 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 448 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 449 | unsigned pcpu; | 449 | unsigned pcpu; |
| 450 | unsigned pscpu; | 450 | unsigned pscpu; |
| 451 | unsigned long stime, utime; | 451 | unsigned long stime, utime; |
diff --git a/libbb/procps.c b/libbb/procps.c index 2f675a544..1e9d6869b 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
| @@ -72,7 +72,7 @@ extern procps_status_t * procps_scan(int save_user_arg0) | |||
| 72 | "%c %d " | 72 | "%c %d " |
| 73 | "%*s %*s %*s %*s " /* pgrp, session, tty, tpgid */ | 73 | "%*s %*s %*s %*s " /* pgrp, session, tty, tpgid */ |
| 74 | "%*s %*s %*s %*s %*s " /* flags, min_flt, cmin_flt, maj_flt, cmaj_flt */ | 74 | "%*s %*s %*s %*s %*s " /* flags, min_flt, cmin_flt, maj_flt, cmaj_flt */ |
| 75 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 75 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 76 | "%lu %lu " | 76 | "%lu %lu " |
| 77 | #else | 77 | #else |
| 78 | "%*s %*s " | 78 | "%*s %*s " |
| @@ -83,12 +83,12 @@ extern procps_status_t * procps_scan(int save_user_arg0) | |||
| 83 | "%*s " /* vsize */ | 83 | "%*s " /* vsize */ |
| 84 | "%ld", | 84 | "%ld", |
| 85 | curstatus.state, &curstatus.ppid, | 85 | curstatus.state, &curstatus.ppid, |
| 86 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 86 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 87 | &curstatus.utime, &curstatus.stime, | 87 | &curstatus.utime, &curstatus.stime, |
| 88 | #endif | 88 | #endif |
| 89 | &tasknice, | 89 | &tasknice, |
| 90 | &curstatus.rss); | 90 | &curstatus.rss); |
| 91 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 91 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 92 | if(n != 6) | 92 | if(n != 6) |
| 93 | #else | 93 | #else |
| 94 | if(n != 4) | 94 | if(n != 4) |
diff --git a/procps/Config.in b/procps/Config.in index 62d2c4fc7..4ce2825dc 100644 --- a/procps/Config.in +++ b/procps/Config.in | |||
| @@ -57,7 +57,7 @@ config CONFIG_TOP | |||
| 57 | The top program provides a dynamic real-time view of a running | 57 | The top program provides a dynamic real-time view of a running |
| 58 | system. | 58 | system. |
| 59 | 59 | ||
| 60 | config ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 60 | config CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 61 | bool " Support showing CPU usage percentage (add 2k bytes)" | 61 | bool " Support showing CPU usage percentage (add 2k bytes)" |
| 62 | default y | 62 | default y |
| 63 | depends on CONFIG_TOP | 63 | depends on CONFIG_TOP |
diff --git a/procps/top.c b/procps/top.c index ddf933d4a..3ab138d29 100644 --- a/procps/top.c +++ b/procps/top.c | |||
| @@ -35,9 +35,9 @@ | |||
| 35 | #include <sys/ioctl.h> | 35 | #include <sys/ioctl.h> |
| 36 | #include "busybox.h" | 36 | #include "busybox.h" |
| 37 | 37 | ||
| 38 | //#define ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE /* + 2k */ | 38 | //#define CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE /* + 2k */ |
| 39 | 39 | ||
| 40 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 40 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 41 | #include <time.h> | 41 | #include <time.h> |
| 42 | #include <sys/time.h> | 42 | #include <sys/time.h> |
| 43 | #include <fcntl.h> | 43 | #include <fcntl.h> |
| @@ -62,7 +62,7 @@ static int mem_sort (procps_status_t *P, procps_status_t *Q) | |||
| 62 | return (int)(Q->rss - P->rss); | 62 | return (int)(Q->rss - P->rss); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 65 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 66 | 66 | ||
| 67 | #define sort_depth 3 | 67 | #define sort_depth 3 |
| 68 | static cmp_t sort_function[sort_depth]; | 68 | static cmp_t sort_function[sort_depth]; |
| @@ -279,7 +279,7 @@ static void do_stats(void) | |||
| 279 | } | 279 | } |
| 280 | #else | 280 | #else |
| 281 | static cmp_t sort_function; | 281 | static cmp_t sort_function; |
| 282 | #endif /* ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE */ | 282 | #endif /* CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE */ |
| 283 | 283 | ||
| 284 | /* display generic info (meminfo / loadavg) */ | 284 | /* display generic info (meminfo / loadavg) */ |
| 285 | static unsigned long display_generic(void) | 285 | static unsigned long display_generic(void) |
| @@ -368,7 +368,7 @@ static void display_status(int count, int col) | |||
| 368 | char rss_str_buf[8]; | 368 | char rss_str_buf[8]; |
| 369 | unsigned long total_memory = display_generic(); | 369 | unsigned long total_memory = display_generic(); |
| 370 | 370 | ||
| 371 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 371 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 372 | /* what info of the processes is shown */ | 372 | /* what info of the processes is shown */ |
| 373 | printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%MEM COMMAND\e[0m\n"); | 373 | printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%MEM COMMAND\e[0m\n"); |
| 374 | #else | 374 | #else |
| @@ -386,7 +386,7 @@ static void display_status(int count, int col) | |||
| 386 | sprintf(rss_str_buf, "%6ldM", s->rss/1024); | 386 | sprintf(rss_str_buf, "%6ldM", s->rss/1024); |
| 387 | else | 387 | else |
| 388 | sprintf(rss_str_buf, "%7ld", s->rss); | 388 | sprintf(rss_str_buf, "%7ld", s->rss); |
| 389 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 389 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 390 | printf("%5d %-8s %s %s %5d %2d.%d %2u.%u ", | 390 | printf("%5d %-8s %s %s %5d %2d.%d %2u.%u ", |
| 391 | s->pid, s->user, s->state, rss_str_buf, s->ppid, | 391 | s->pid, s->user, s->state, rss_str_buf, s->ppid, |
| 392 | s->pcpu/10, s->pcpu%10, pmem/10, pmem%10); | 392 | s->pcpu/10, s->pcpu%10, pmem/10, pmem%10); |
| @@ -422,7 +422,7 @@ static void reset_term(void) | |||
| 422 | tcsetattr(0, TCSANOW, (void *) &initial_settings); | 422 | tcsetattr(0, TCSANOW, (void *) &initial_settings); |
| 423 | #ifdef CONFIG_FEATURE_CLEAN_UP | 423 | #ifdef CONFIG_FEATURE_CLEAN_UP |
| 424 | clearmems(); | 424 | clearmems(); |
| 425 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 425 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 426 | free(save_history); | 426 | free(save_history); |
| 427 | #endif | 427 | #endif |
| 428 | #endif /* CONFIG_FEATURE_CLEAN_UP */ | 428 | #endif /* CONFIG_FEATURE_CLEAN_UP */ |
| @@ -463,7 +463,7 @@ int top_main(int argc, char **argv) | |||
| 463 | /* Default to 25 lines - 5 lines for status */ | 463 | /* Default to 25 lines - 5 lines for status */ |
| 464 | lines = 25 - 5; | 464 | lines = 25 - 5; |
| 465 | /* Default CMD format size */ | 465 | /* Default CMD format size */ |
| 466 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 466 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 467 | col = 35 - 6; | 467 | col = 35 - 6; |
| 468 | #else | 468 | #else |
| 469 | col = 35; | 469 | col = 35; |
| @@ -491,7 +491,7 @@ int top_main(int argc, char **argv) | |||
| 491 | get_terminal_width_height(0, &col, &lines); | 491 | get_terminal_width_height(0, &col, &lines); |
| 492 | if (lines > 4) { | 492 | if (lines > 4) { |
| 493 | lines -= 5; | 493 | lines -= 5; |
| 494 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 494 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 495 | col = col - 80 + 35 - 6; | 495 | col = col - 80 + 35 - 6; |
| 496 | #else | 496 | #else |
| 497 | col = col - 80 + 35; | 497 | col = col - 80 + 35; |
| @@ -499,13 +499,13 @@ int top_main(int argc, char **argv) | |||
| 499 | } | 499 | } |
| 500 | #endif /* CONFIG_FEATURE_USE_TERMIOS */ | 500 | #endif /* CONFIG_FEATURE_USE_TERMIOS */ |
| 501 | 501 | ||
| 502 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 502 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 503 | sort_function[0] = pcpu_sort; | 503 | sort_function[0] = pcpu_sort; |
| 504 | sort_function[1] = mem_sort; | 504 | sort_function[1] = mem_sort; |
| 505 | sort_function[2] = time_sort; | 505 | sort_function[2] = time_sort; |
| 506 | #else | 506 | #else |
| 507 | sort_function = mem_sort; | 507 | sort_function = mem_sort; |
| 508 | #endif /* ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE */ | 508 | #endif /* CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE */ |
| 509 | 509 | ||
| 510 | while (1) { | 510 | while (1) { |
| 511 | /* read process IDs & status for all the processes */ | 511 | /* read process IDs & status for all the processes */ |
| @@ -520,7 +520,7 @@ int top_main(int argc, char **argv) | |||
| 520 | if (ntop == 0) { | 520 | if (ntop == 0) { |
| 521 | bb_perror_msg_and_die("scandir('/proc')"); | 521 | bb_perror_msg_and_die("scandir('/proc')"); |
| 522 | } | 522 | } |
| 523 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 523 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 524 | if(!Hertz) { | 524 | if(!Hertz) { |
| 525 | init_Hertz_value(); | 525 | init_Hertz_value(); |
| 526 | do_stats(); | 526 | do_stats(); |
| @@ -531,7 +531,7 @@ int top_main(int argc, char **argv) | |||
| 531 | do_stats(); | 531 | do_stats(); |
| 532 | #else | 532 | #else |
| 533 | qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function); | 533 | qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function); |
| 534 | #endif /* ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE */ | 534 | #endif /* CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE */ |
| 535 | opt = lines; | 535 | opt = lines; |
| 536 | if (opt > ntop) { | 536 | if (opt > ntop) { |
| 537 | opt = ntop; | 537 | opt = ntop; |
| @@ -551,7 +551,7 @@ int top_main(int argc, char **argv) | |||
| 551 | if(c == 'q' || c == initial_settings.c_cc[VINTR]) | 551 | if(c == 'q' || c == initial_settings.c_cc[VINTR]) |
| 552 | return EXIT_SUCCESS; | 552 | return EXIT_SUCCESS; |
| 553 | if(c == 'M') { | 553 | if(c == 'M') { |
| 554 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 554 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 555 | sort_function[0] = mem_sort; | 555 | sort_function[0] = mem_sort; |
| 556 | sort_function[1] = pcpu_sort; | 556 | sort_function[1] = pcpu_sort; |
| 557 | sort_function[2] = time_sort; | 557 | sort_function[2] = time_sort; |
| @@ -559,7 +559,7 @@ int top_main(int argc, char **argv) | |||
| 559 | sort_function = mem_sort; | 559 | sort_function = mem_sort; |
| 560 | #endif | 560 | #endif |
| 561 | } | 561 | } |
| 562 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 562 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 563 | if(c == 'P') { | 563 | if(c == 'P') { |
| 564 | sort_function[0] = pcpu_sort; | 564 | sort_function[0] = pcpu_sort; |
| 565 | sort_function[1] = mem_sort; | 565 | sort_function[1] = mem_sort; |
| @@ -572,7 +572,7 @@ int top_main(int argc, char **argv) | |||
| 572 | } | 572 | } |
| 573 | #endif | 573 | #endif |
| 574 | if(c == 'N') { | 574 | if(c == 'N') { |
| 575 | #ifdef ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 575 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
| 576 | sort_function[0] = pid_sort; | 576 | sort_function[0] = pid_sort; |
| 577 | #else | 577 | #else |
| 578 | sort_function = pid_sort; | 578 | sort_function = pid_sort; |
