diff options
author | John Baldwin <jhb@FreeBSD.org> | 2011-07-11 16:48:52 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2011-07-11 16:48:52 +0000 |
commit | 51f202e9eda2c96a83444e213239bb267eb4ab47 (patch) | |
tree | 24dbd2ed39f324b805699359b163b92f96dd4012 /contrib/top | |
parent | e24134bc0ed53f9d85377c4a645f2e86c9dc677c (diff) | |
download | src-51f202e9eda2c96a83444e213239bb267eb4ab47.tar.gz src-51f202e9eda2c96a83444e213239bb267eb4ab47.zip |
Allow per-CPU statistics to be toggled at runtime via the 'P' key.
While here, make -P a toggle similar to other options such as -I.
Reviewed by: arundel
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=223936
Diffstat (limited to 'contrib/top')
-rw-r--r-- | contrib/top/commands.c | 1 | ||||
-rw-r--r-- | contrib/top/display.c | 21 | ||||
-rw-r--r-- | contrib/top/top.X | 4 | ||||
-rw-r--r-- | contrib/top/top.c | 19 |
4 files changed, 37 insertions, 8 deletions
diff --git a/contrib/top/commands.c b/contrib/top/commands.c index 7891068a2517..49472fd13668 100644 --- a/contrib/top/commands.c +++ b/contrib/top/commands.c @@ -88,6 +88,7 @@ o - specify sort order (vcsw, ivcsw, read, write, fault, total, jid)\n", stdout); #endif fputs("\ +P - toggle the displaying of per-CPU statistics\n\ r - renice a process\n\ s - change number of seconds to delay between updates\n\ S - toggle the displaying of system processes\n\ diff --git a/contrib/top/display.c b/contrib/top/display.c index 8d89d825a33b..a5a4e9e9f423 100644 --- a/contrib/top/display.c +++ b/contrib/top/display.c @@ -151,16 +151,14 @@ int display_resize() return(smart_terminal ? lines : Largest); } -int display_init(statics) +int display_updatecpus(statics) struct statics *statics; { register int lines; - register char **pp; - register int *ip; register int i; - + /* call resize to do the dirty work */ lines = display_resize(); num_cpus = statics->ncpus; @@ -170,6 +168,21 @@ struct statics *statics; for (i = num_cpus; i > 9; i /= 10) cpustates_column++; + return(lines); +} + +int display_init(statics) + +struct statics *statics; + +{ + register int lines; + register char **pp; + register int *ip; + register int i; + + lines = display_updatecpus(statics); + /* only do the rest if we need to */ if (lines > -1) { diff --git a/contrib/top/top.X b/contrib/top/top.X index 7c93a2e64277..9c54f85637e8 100644 --- a/contrib/top/top.X +++ b/contrib/top/top.X @@ -205,6 +205,7 @@ The options .BR \-H , .BR \-I , .BR \-j , +.BR \-P , .BR \-S , .BR \-t , .BR \-u , @@ -314,6 +315,9 @@ Toggle the display of .IR jail (8) ID. .TP +.B P +Toggle the display of per-CPU statistics. +.TP .B t Toggle the display of the .I top diff --git a/contrib/top/top.c b/contrib/top/top.c index 6673a2768846..896338593df3 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -196,9 +196,9 @@ char *argv[]; fd_set readfds; #ifdef ORDER - static char command_chars[] = "\f qh?en#sdkriIutHmSCajzo"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPo"; #else - static char command_chars[] = "\f qh?en#sdkriIutHmSCajz"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCajzP"; #endif /* these defines enumerate the "strchr"s of the commands in command_chars */ #define CMD_redraw 0 @@ -225,8 +225,9 @@ char *argv[]; #define CMD_showargs 20 #define CMD_jidtog 21 #define CMD_kidletog 22 +#define CMD_pcputog 23 #ifdef ORDER -#define CMD_order 23 +#define CMD_order 24 #endif /* set the buffer for stdout */ @@ -411,7 +412,7 @@ char *argv[]; break; case 'P': - pcpu_stats = Yes; + pcpu_stats = !pcpu_stats; break; case 'z': @@ -1088,6 +1089,16 @@ restart: ps.kidle ? "D" : "Not d"); putchar('\r'); break; + case CMD_pcputog: + pcpu_stats = !pcpu_stats; + new_message(MT_standout | MT_delayed, + " Displaying %sCPU statistics.", + pcpu_stats ? "per-" : "global "); + toggle_pcpustats(&statics); + max_topn = display_updatecpus(&statics); + reset_display(); + putchar('\r'); + break; default: new_message(MT_standout, " BAD CASE IN SWITCH!"); putchar('\r'); |