Commit Graph

37 Commits

Author SHA1 Message Date
Enji Cooper
96331b7705 Silence top(1) compiler warnings
The contrib/top code is no longer maintained upstream (last pulled 16 years
ago). The K&R-style followed by the code spews -Wimplicit-int and -Wreturn-type
warnings, amongst others. This silences 131 warnings with as little modification
as possible by adding necessary return types, definitions, headers, and header
guards, and missing header includes.

The 5 warnings that remain are due to undeclared ncurses references. I didn't
include curses.h and term.h because there are several local functions and macros
that conflict with those definitions.

MFC after: 3 weeks
Reviewed by: cem, ngie
Submitted by: Randy Westlund <rwestlun@gmail.com>
Differential Revision: https://reviews.freebsd.org/D6468
2016-05-22 04:17:00 +00:00
Bryan Drewery
ee92dd81a5 - Add a hint for 'u' and 'J' command that '+' displays all.
MFC after:	2 weeks
2014-05-02 23:32:44 +00:00
Bryan Drewery
1b60f97272 Add -J command/flag to filter by jail name/jid. This will automatically
display the JID as well (the -j command/flag).

  0 displays host.
  + displays all.

MFC after:	2 weeks
Relnotes:	yes
2014-05-02 23:30:39 +00:00
John Baldwin
2e52fb92ff Add a new line to top that provides a brief summary of the ZFS ARC memory
usage on hosts using ZFS.  The new line displays the total amount of RAM
used by the ARC along with the size of MFU, MRU, anonymous (in flight),
headers, and other (miscellaneous) sub-categories.  The line is not
displayed on systems that are not using ZFS.

Reviewed by:	avg, fs@
MFC after:	3 days
2012-06-27 18:08:48 +00:00
Konstantin Belousov
d9514f6739 In batch mode, exit after receiving SIGINT, instead of immediate
output of the next display.

Submitted by:	Andrey Zonov <andrey zonov org>
MFC after:	1 week
2012-03-07 18:05:45 +00:00
Konstantin Belousov
963a74f13c Fix a race in top non-interactive mode. Use plain sleep(3) call instead
of arming timer and then pausing.  If SIGALRM is delivered before pause(3)
is entered, top hangs.

Submitted by:	Andrey Zonov <andrey zonov org>
MFC after:	1 week
2012-02-27 20:52:20 +00:00
John Baldwin
fcc3d62fa5 Rework the dynamic per-CPU stats code a bit. Always set 'statics->ncpus'
to the maximum number of CPUs to ensure that lcpustates[] array is always
allocated to the maximum size.  Previously, if top was started without
per-CPU stats it would allocate a smaller lcpustates[] array.  When
per-CPU stats were then enabled, it would overflow the array and trash
the cpustates_columns[] array causing the CPU stats to be printed in the
wrong locations.

Approved by:	re (kib)
MFC after:	1 week
2011-07-18 21:15:47 +00:00
John Baldwin
834377fe2d Tweak the interactive description of CPU vs WCPU.
PR:		bin/158819
Submitted by:	arundel
Approved by:	re (kib)
2011-07-18 21:08:14 +00:00
John Baldwin
4702b8d2c0 Add a leading space to the status messages output after toggling the
'C' and 'H' flags at runtime.  This matches messages output for other
toggles which leave the first column in the message blank to hold the
cursor.

PR:		bin/158775
Submitted by:	arundel
MFC after:	3 days
2011-07-11 16:51:29 +00:00
John Baldwin
51f202e9ed 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
2011-07-11 16:48:52 +00:00
John Baldwin
c9385548e7 Add a new option to toggle the display of the system idle process (per-CPU
idle threads).  The process is displayed by default (subject to whether or
not system processes are displayed) to preserve existing behavior.  The
system idle process can be hidden via the '-z' command line argument or the
'z' key while top is running.  When it is hidden, top more closely matches
the behavior of FreeBSD <= 4.x where idle time was not accounted to any
process.

MFC after:	2 weeks
2011-05-31 15:11:23 +00:00
Ruslan Ermilov
cd83aa9707 Removed the no-op -p; documented -P.
MFC after:	3 days
2008-06-21 15:48:16 +00:00
Peter Wemm
031175705e Add a -P flag to display per-cpu cpu usage stats. 2008-01-18 01:43:14 +00:00
David E. O'Brien
dbb2956620 Improve -u (limit uid lookups) behavior.
Submitted by:	David Frascone <dave@frascone.com>
PR:		119490
2008-01-09 18:06:24 +00:00
Rong-En Fan
d3abf70e1b - s/jail id/jail ID/, acronyms should be in uppercase in general. Also,
it is written this way in jail(8).

Suggested by:	brueffer
Approved by:	delphij (mentor, implicit)
2007-05-04 15:42:58 +00:00
Rong-En Fan
926a99d402 - Add new 'a' and 'j' options into usage
Approved by:	delphij (mentor, implicit)
Forgotten by:	stas ('a') and rafan ('j')
2007-04-19 14:24:54 +00:00
Rong-En Fan
6000ced11b - Add a new 'j' switch and runtime option to toggle display jail id for
each process.
- While I'm here, keep help message sorted by keys

PR:		98489, 98975
Submitted by:	clsung
Approved by:	delphij (mentor)
MFC after:	2 weeks
2007-04-17 03:12:39 +00:00
Stanislav Sedov
faac60c8fc - Add new 'a' switch and runtime option that allows 'top' to display process
titles extracted from argv vector instead of the real executable names.
  This is useful when you want to watch applications that set their status
  information via setproctitle(3).

Approved by:	alfred
MFC after:	2 weeks
2007-04-14 10:16:52 +00:00
Ruslan Ermilov
c8e1eaa0a4 Re-add option -C to usage(). 2006-04-19 12:19:06 +00:00
Ruslan Ermilov
7734a577e3 Bring SYNOPSIS in line with usage(). 2006-04-18 15:26:58 +00:00
Giorgos Keramidas
bbf750fbff Merge the CPU and WCPU columns in a single %6.2f column, add a new 'C'
command that toggles between the two and update the ORDER_PCTCPU()
macro to sort correctly by the visible "cpu" value.

This saves 6 more columns in 80-column terminals, making things a lot
better for the COMMAND column.

Tested on:	i386, sparc64 (panther), amd64 (sledge)
Approved by:	davidxu (in principle)
2005-05-18 13:30:08 +00:00
Giorgos Keramidas
32efd26355 - Add a THR column to the process listing, that shows the number of
threads a process has.  The THR column is disabled and disappears
  when 'H' is hit, because then every thread gets its own output line.
- Allow sorting processes by "threads".

Approved by:	davidxu
Inspired by:	Jiawei Ye <leafy7382@gmail.com>
2005-04-14 15:02:03 +00:00
Alfred Perlstein
5d320d4b95 This patch merges the sort fields for both pages, so you can (for
example) view io stats while sorting by process size.  Also adds
voluntary and involuntary context-switch stats to the io page because
there was lots of room.

Submitted by: Dan Nelson dnelson at allantgroup.com
2004-08-16 07:51:22 +00:00
Alfred Perlstein
3911ee527b Make 'S' in interactive mode toggle display of system processes. 2004-07-12 03:00:50 +00:00
Giorgos Keramidas
26b2243ae7 Build upon the nice work of Alfred and add sorting capabilities to
the -m "io" mode of top.

Approved by:	alfred
2004-07-08 16:45:55 +00:00
Dag-Erling Smørgrav
ba2396cd27 Correct a misleading (cut'n'pasted) comment. 2004-07-05 12:19:53 +00:00
Alfred Perlstein
db6bb7fc01 New feature, provide a display that shows the amount of IO processes
are doing.  Toggle this mode by hitting "m" or passing the command line
option "-m io" to top(1).  This allows one to identify disk bandwidth
hogs much easier.
2004-07-01 09:12:38 +00:00
Julian Elischer
e27d79bb28 Changes to allow top to decide whether or not to show multiple threads per
process. Option -H enables it and it is toggled at the interactive
screen by 'H'.

Submitted by:	Jung-uk Kim <jkim@niksun.com>
2003-07-17 23:56:40 +00:00
David Malone
db6a108dbf Resolve conflicts (our -t option, we'd fixed a bug in a slightly different way). 2002-01-24 17:55:40 +00:00
David Malone
3d08935d6a Make top exit if its tty vanishes.
PR:		30939, 30581
Submitted by:	Edwin Groothuis <edwin@mavetju.org>
Submitted by: 	Andrew L. Neporada <andr@dgap.mipt.ru>
MFC after:	2 weeks
2001-11-04 21:15:52 +00:00
Kris Kennaway
26d889d4ff Don't do unsafe activities inside signal handlers. Just set a flag and
return.

Obtained from:	OpenBSD
Reviewed by:	audit
2001-08-06 03:19:22 +00:00
Warner Losh
70cf0d7ec3 Fix another possible bufer overflow in top.
PR: bin/22496
2000-11-03 22:00:10 +00:00
Warner Losh
1e3661ab60 display.c: sprintf -> snprintf
top.c: fix from NetBSD/OpenBSD: make sure that new_message() is called
with a format.

Add $FreeBSD$ While I'm here.

These files are already off the vendor branch.
2000-10-04 23:34:16 +00:00
David E. O'Brien
a2641311ff uptime display more in style with original code 1999-01-09 20:25:02 +00:00
Dag-Erling Smørgrav
e7cdb97253 Add -t option ('t' in interactive mode) to make top(1) ignore itself.
Attempts to contact the author of top(1) (William LeFebvre) have so
far been unsuccessful.

PR:		7253
Submitted by:	Yours Truly
1998-08-04 14:10:48 +00:00
Joerg Wunsch
6ab598d69b Apply the FreeBSD-local patches.
Obtained from:	The ports collection.
1997-03-23 18:53:01 +00:00
Joerg Wunsch
aee34003d7 This is the long-awaited import of top into the base system (actually,
the src/contrib/top part right now).  This tools is simply too system-
dependant to maintain it in the ports collection.
1997-03-23 18:51:21 +00:00