diff options
author | des <des@FreeBSD.org> | 2016-10-22 00:35:40 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2016-10-22 00:35:40 +0000 |
commit | 1ff7db8d3694a80c7eebb4556936158d0574df40 (patch) | |
tree | 84f2f8efbbf8d8617c2f260ba85ef020872834fc /contrib | |
parent | bed8fd1318d780ae7e6d8ae485b182ace2397810 (diff) | |
download | FreeBSD-src-1ff7db8d3694a80c7eebb4556936158d0574df40.zip FreeBSD-src-1ff7db8d3694a80c7eebb4556936158d0574df40.tar.gz |
MFH (r305414): add a toggle to show approximate swap usage.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/top/commands.c | 1 | ||||
-rw-r--r-- | contrib/top/machine.h | 5 | ||||
-rw-r--r-- | contrib/top/top.c | 23 | ||||
-rw-r--r-- | contrib/top/top.xs | 25 |
4 files changed, 40 insertions, 14 deletions
diff --git a/contrib/top/commands.c b/contrib/top/commands.c index 53a45ee..7114fcf 100644 --- a/contrib/top/commands.c +++ b/contrib/top/commands.c @@ -104,6 +104,7 @@ S - toggle the displaying of system processes\n\ a - toggle the displaying of process titles\n\ t - toggle the display of this process\n\ u - display processes for only one user (+ selects all users)\n\ +w - toggle the display of swap use for each process\n\ z - toggle the displaying of the system idle process\n\ \n\ \n", stdout); diff --git a/contrib/top/machine.h b/contrib/top/machine.h index 3aad758..6f2844d 100644 --- a/contrib/top/machine.h +++ b/contrib/top/machine.h @@ -72,6 +72,7 @@ struct process_select int wcpu; /* show weighted cpu */ int jid; /* only this jid (unless jid == -1) */ int jail; /* show jail ID */ + int swap; /* show swap usage */ int kidle; /* show per-CPU idle threads */ char *command; /* only this command (unless == NULL) */ }; @@ -82,8 +83,8 @@ char *format_header(); char *format_next_process(); void toggle_pcpustats(void); void get_system_info(struct system_info *si); -int machine_init(struct statics *statics, char do_unames); -int proc_owner(int pid); +int machine_init(struct statics *statics, char do_unames); +int proc_owner(int pid); /* non-int routines typically used by the machine dependent module */ char *printable(); diff --git a/contrib/top/top.c b/contrib/top/top.c index 64c3d5f..c74c1d1 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -188,9 +188,9 @@ char *argv[]; fd_set readfds; #ifdef ORDER - static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJo"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJwo"; #else - static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJ"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJw"; #endif /* these defines enumerate the "strchr"s of the commands in command_chars */ #define CMD_redraw 0 @@ -219,8 +219,9 @@ char *argv[]; #define CMD_kidletog 22 #define CMD_pcputog 23 #define CMD_jail 24 +#define CMD_swaptog 25 #ifdef ORDER -#define CMD_order 25 +#define CMD_order 26 #endif /* set the buffer for stdout */ @@ -254,6 +255,7 @@ char *argv[]; ps.wcpu = 1; ps.jid = -1; ps.jail = No; + ps.swap = No; ps.kidle = Yes; ps.command = NULL; @@ -280,7 +282,7 @@ char *argv[]; optind = 1; } - while ((i = getopt(ac, av, "CSIHPabijJ:nquvzs:d:U:m:o:t")) != EOF) + while ((i = getopt(ac, av, "CSIHPabijJ:nquvzs:d:U:m:o:tw")) != EOF) { switch(i) { @@ -418,6 +420,10 @@ char *argv[]; pcpu_stats = !pcpu_stats; break; + case 'w': + ps.swap = 1; + break; + case 'z': ps.kidle = !ps.kidle; break; @@ -1141,6 +1147,15 @@ restart: reset_display(); putchar('\r'); break; + case CMD_swaptog: + ps.swap = !ps.swap; + new_message(MT_standout | MT_delayed, + " %sisplaying per-process swap usage.", + ps.swap ? "D" : "Not d"); + header_text = format_header(uname_field); + reset_display(); + putchar('\r'); + break; default: new_message(MT_standout, " BAD CASE IN SWITCH!"); putchar('\r'); diff --git a/contrib/top/top.xs b/contrib/top/top.xs index 15cf2dc..d3829f3 100644 --- a/contrib/top/top.xs +++ b/contrib/top/top.xs @@ -10,7 +10,7 @@ top \- display and update information about the top cpu processes .SH SYNOPSIS .B top [ -.B \-abCHIijnPqStuvz +.B \-abCHIijnPqStuvwz ] [ .BI \-d count ] [ @@ -148,6 +148,9 @@ Write version number information to stderr then exit immediately. No other processing takes place when this option is used. To see current revision information while top is running, use the help command \*(lq?\*(rq. .TP +.B \-w +Display approximate swap usage for each process. +.TP .B \-z Do not display the system idle process. .TP @@ -167,11 +170,12 @@ Set the delay between screen updates to seconds. The default delay between updates is \nD seconds. .TP .BI \-o field -Sort the process display area on the specified field. The field name is -the name of the column as seen in the output, but in lower case. Likely -values are \*(lqcpu\*(rq, \*(lqsize\*(rq, \*(lqres\*(rq, and \*(lqtime\*(rq, -but may vary on different operating systems. Note that -not all operating systems support this option. +Sort the process display area on the specified field. The field name +is the name of the column as seen in the output, but in lower case: +\*(lqcpu\*(lq, \*(rqsize\*(lq, \*(rqres\*(lq, \*(rqtime\*(lq, +\*(rqpri\*(lq, \*(rqthreads\*(lq, \*(lqtotal\*(lq, \*(rqread\*(lq, +\*(rqwrite\*(lq, \*(rqfault\*(lq, \*(rqvcsw\*(lq, \*(rqivcsw\*(lq, +\*(lqjid\*(lq, \*(rqswap\*(lq or \*(rqpid\*(lq. .TP .BI \-J jail Show only those processes owned by @@ -226,6 +230,7 @@ The options .BR \-S , .BR \-t , .BR \-u , +.BR \-w , and .B \-z are actually toggles. A second specification of any of these options @@ -346,6 +351,9 @@ Toggle the display of the .I top process. .TP +.B w +Toggle the display of swap usage. +.TP .B z Toggle the display of the system idle process. .SH "THE DISPLAY" @@ -379,8 +387,9 @@ is specified, a UID column will be substituted for USERNAME), PRI is the current priority of the process, NICE is the nice amount (in the range \-20 to 20), SIZE is the total size of the process (text, data, and stack), -RES is the current amount of resident memory (both SIZE and RES are -given in kilobytes), +RES is the current amount of resident memory, +SWAP is the approximate amount of swap, if enabled +(SIZE, RES and SWAP are given in kilobytes), STATE is the current state (one of \*(lqSTART\*(rq, \*(lqRUN\*(rq (shown as \*(lqCPUn\*(rq on SMP systems), \*(lqSLEEP\*(rq, \*(lqSTOP\*(rq, \*(lqZOMB\*(rq, \*(lqWAIT\*(rq, \*(lqLOCK\*(rq or the event on which the |