Commit Graph

96 Commits

Author SHA1 Message Date
Alexander Motin
8d2419b571 Make systat -vmstat to use suffixes to display big floating point numbers
that are not fitting into the specified field width, same as done for ints.
In particular that allows to properly display disk tps above 100k, that are
reachable with modern SSDs.
2013-03-23 13:11:54 +00:00
Andrey Zonov
9c02dc3399 - Show page faults requiring I/O on vmstat display.
Reviewed by:	alc
MFC after:	2 weeks
2013-01-28 12:57:42 +00:00
Ed Schouten
2bd338d6c4 Fix whitespace inconsistencies in systat(1).
According to md5(1), the resulting binary is the same.
2011-10-15 13:20:36 +00:00
Joel Dahl
da52b4caaf Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
Alexander Motin
4b06d6510d For total interrupt count on -vm screen count all interrupts, but not only
those which fit the screen.
2010-09-08 07:30:46 +00:00
Alexander Motin
f91b7a2526 Partially revert r209312, restoring ability to fit "stray irqX" names into
into available 10 characters by dropping "irq" in the middle of string.
2010-07-19 02:26:59 +00:00
Alexander Motin
cb9c9783b4 Do not print first digits of IRQ number if whole number doesn't fit. 2010-06-18 18:18:03 +00:00
Ed Schouten
ab90a4d1e2 Perform all trivial ports to utmpx for usr.bin/.
They were already converted to use libulog, so it's easy to convert them
to utmpx.
2010-01-13 18:09:54 +00:00
Xin LI
821df508e8 Revert most part of 200420 as requested, as more review and polish is
needed.
2009-12-13 03:14:06 +00:00
Xin LI
6f2d322192 Remove unneeded header includes from usr.bin/ except contributed code.
Tested with:	make universe
2009-12-11 23:35:38 +00:00
Ed Schouten
3487b13416 Let systat's vmstat use utmpx. 2009-12-05 20:52:11 +00:00
John Baldwin
a0b9e7e332 Update top and systat for vfs.bufcache now being a long rather than an int. 2009-03-10 15:25:19 +00:00
Xin LI
93b9f50404 ANSIfy and remove register.
Resulting binary verified with strip(1)+md5(1).
2008-01-16 19:27:43 +00:00
Ruslan Ermilov
bad4d172b4 - Revert signedness type changes to "struct vmtotal"; by making
them unsigned I made the possible overflows hard to detect,
  and it only saved 1 bit which isn't principal, even less now
  that the underlying issue with the total of virtual memory has
  been fixed.  (For the record, it will overflow with >=2T of
  VM total, with 32-bit ints used to keep counters in pages.)

- While here, fix printing of other "struct vmtotal" members
  such as t_rq, t_dw, t_pw, and t_sw as they are also signed.

Reviewed by:	bde
MFC after:	3 days
2006-11-28 12:46:02 +00:00
Ruslan Ermilov
20739dfa44 Fix the format specifier suitable for uintmax_t. 2006-11-23 11:51:23 +00:00
Ruslan Ermilov
5c88a11e6e - Fix types of "struct vmmeter" members so they are unsigned.
- Fix overflow bugs in sysctl(8), systat(1), and vmstat(8)
  when printing values of "struct vmmeter" in kilobytes as
  they don't necessarily fit into 32 bits.  (Fix sysctl(8)
  reporting of a total virtual memory; it's in pages too.)
2006-11-20 16:04:41 +00:00
Bruce Evans
04984aac91 For the vmstat sub-display:
vmstat.c:
Move totfr to be under daefr and prcfr since it logically belongs there.

Move all the count fields (wire, act, inact, cache and free) to near
the bottom of the sub-display (after all the rate fields) to reduce
competition with adjoining sub-displays.

systat.1:
Move things as above.

Attempt to improve missing and poor wording in the description of the
fields.  The long sentence was hard to parse and didn't say anything
about the different units.

Increment .Dd.
2006-05-01 07:02:52 +00:00
Bruce Evans
74a2149c90 Unbreak the support for 24-row terminals in the vmstat display. The
part that handled the 17th and 18th rows of the vmstat-proper subdisplay
was deleted in rev.1.10 when these rows stopped being used and was not
restored when the 17th row was used again.  For such terminals, we now
lose the `buf' field instead of making a mess with it.  Terminals with
fewer than 24 rows have never been supported.

The problem is not avoided by using curses since we use the last line
for data entry and don't use a separate subwindow for this line.
Some other things in the vmstat display could be handled better using
subwindows.
2006-05-01 00:26:43 +00:00
Bruce Evans
1247d9c61c Sort the ex-extended vmstat fields into their documented order in the
output too.

Fine tune all coordinates and most field widths in the vmstat (sub)display
for this and previous changes now that we have to change almost all of them
just to move the ex-extended fields:
- change VMSTATROW back to 7.  It was 6 due to a hack in the extended vm
  stats changes.
- reduce the maximum field width that we try for from 9 to 8.  4 or 5 is
  enough for most fields but we try to use the same width for all fields.
  8 is enough to display everything without changing units memory sizes
  exceed 100GB.

Fix some unrelated coordinates and field widths in comments.
2006-04-30 23:52:16 +00:00
Bruce Evans
de9a857e4c Eliminate the "extended" vm stats. Move all fields in the extended
vm stats to the normal vm stats.  Sort them into the normal stats
according to the man page only in the source code so that diffs are
almost readable.  Reduce style bugs in printing the value of %ozfod.
2006-04-30 22:34:54 +00:00
Bruce Evans
9177eda617 Reduce the namei (sub)display by 5 columns to make enough space for a
new vnstat display to the right of the namei display.

Move the non-vmstat fields {des,num,fre}vn from the vmstat display to a
new vnstat display.  Move the dtbuf field there too.  The buf and dtbuf
fields are non-vmstat and non-vnstat, so there is no good place to
display them.  I need to move at least 1 of them out of the vm stats
for further cleanups of the vm stats, and there is only space for 1
of them in the vn stats.  (The best place for the current buf field
is actually /dev/null, since it has been completely broken for about
10 years and broken for longer.  It gives an uninteresting virtual
memory count where an interesting real memory count is wanted.)
2006-04-30 20:31:00 +00:00
Bruce Evans
3bccedcdf8 Don't redraw the disk names on every update. This was apparently done
to handle changes to the set of disks selected, but it is unnecessary
for that since the whole screen is redrawn when this set is changed.
It was also buggy:
- MAXDRIVES*6 = 42 was hard-coded as only 30 spaces in a string literal,
  the last 2 disk names were not cleared as intended
- when the extended vmstats are active, clearing of even 30 columns
  overruns the ozfod value field by 3 columns.  This was harmless because
  the field is much wider than necessary.
2006-04-30 09:13:59 +00:00
Bruce Evans
6e977072c6 Fix "slow (on-the-fly) zero fills percentage (`%slo-z')" some more. The
value printed is actually the optimized (i.e., the non-slow, not-on-the-fly
zero fills percentage) except in overflow cases.  Describe it as %ozfod
in the display.  Move the field descriptor 1 to the left so that there
is space for 5 characters after the % sign (this leaves no space between
the number and the descriptor but the % character serves well as a
separator).

Fixed integer overflow at z.ozfod = UINT_MAX/100 in the calculation of
%ozfod.  This value can be reached just a few hours or minutes after
booting, so %ozfod was usually garbage in boot mode.  Now %ozfod is
correct in boot mode for a few days or hours.

Print a non-dummy %ozfod when the division for it isn't division by 0
instead of when the result will be less than 100%.  A result of 100%
may be correct, though a result of more than 100% indicates overflow
of one or both counters.
2006-04-30 07:27:23 +00:00
Bruce Evans
43f2757a27 If DEBUG is defined, then fill numeric fields with asterisks instead of
spaces and numbers for temporary(?) debugging.
2006-04-30 05:54:21 +00:00
Bruce Evans
4545c62547 Edit the interrupt name strings to shorten them. This is believed to
only affect amd64 and i386.  alpha uses "intr N" instead of "irqN" and
mostly has no device names.  ia64 uses only device names.

- Edit interrupt names once after they are read from the kernel and not
  every time they are displayed.
- Discard bogus trailing spaces so that the next step doesn't move things
  to oblivion.
- If an interrupt name starts with "irqN:" (as it usually does in on
  amd64 and i386), then move "irqN" to the end and strip ":", since we
  have no space for the ":" and don't want to start descriptions with
  "N" after stripping "irq" in the next step (since "N" would look like
  a count).  This step may need reworking for interrupt names containing
  several device names -- then moving the irq number to the end would
  lose it instead of losing some device names.
- Remove "irq" from an interrupt name if and only if the original name is
  too long to display.
2006-04-30 01:39:46 +00:00
Bruce Evans
18d3a03e13 Backed out rev.1.49 since it had buffer overruns and only worked
accidentally.

Read buffer overruns:
The size of the target array (TSOTTA == 10) is a wrong limit to use for
scanning the source string.

Write buffer overruns:
TSOTTA is also a wrong limit to use for copying to the target buffer,
since we want to add a NUL terminator afterwards.  TSOTTA was also 1
too small for holding both the desired number of visible characters
and the NUL.

Worked accidentally:
There is error in the algorithm that tends to result in the space saved
by stripping "irq" not actually being used, but some cases worked
accidentally provided "irqN" is near the end of the source string and
"N" is only 1 digit.

Starting with 5.mumble-CURRENT, "irqN" is at the beginning of the
string on all (?) arches that have it and the accidents don't happen.
E.g. on i386's, the keyboard irq is now named
"irq1: atkbd0<bogus blank padding>" by the kernel, and this name was
converted to "1: atkb" -- not only the device number but part of the
device name has been lost --, while before 5.mumble the kernel name
was "atkbd0 irq1" and systat accidentally preserved the irq number to
give "atkbd0 1".  The ":" in the string wastes precious space, and
stripping "irq" results in descriptions starting with numbers which
makes them look too much like counts.  This commit just fixes the last
problem.
2006-04-30 00:50:08 +00:00
Bruce Evans
e76bdda079 Abbreviate long field descriptors at write time so that they don't get
clobbered at runtime:
    dirtybuf -> dtbuf
    desiredvnodes -> desvn
    numvnodes -> numvn
    freevnodes -> frevn
The vmstats column has only 5 characters available for descriptors, but up
to 13 were used.  The extras get clobbered at runtime by interrupt values
and/or descriptors on systems with more than 12 interrupt sources.
    %slo-z -> %sloz
This one is in the "extended" vmstats area and doesn't get clobbered now.

Removed stale documentation of desvn.

Changed a descriptor:
    tfree -> totfr
so that it is consistent with the abbreviations for other free counts
(daefr and prcfr) and thus almost decodeable.

Fixed missing documentation of tfree/totfr.  This and everything else
in the extended vmstats area is misdocumented as being in a certain
place in the vmstats column.
2006-04-29 21:30:23 +00:00
John-Mark Gurney
244bb595f4 fix spelling of ozfod... I've been wondering why we'd need to fill a page
w/ non-zero data, and it turns out we don't...  This is really optimized
zero filled on demand, or pages that were already zero'd for us...

MFC after:	3 days
2006-03-18 01:06:13 +00:00
Bruce Evans
8d40843ab4 Move the "r p d s w" fields to the left to create space for expansion.
3 columns were wasted at the left, except these columns were used to
make the header line up.  Now there is no space on the same line for
the "Proc:" part of the header.  Try putting this on the line above
although it clutters that line (there is already similar clutter for
the "Interrupts" header).  Leave 1 column between these fields.  With
the above and a previous change there is enough of space for this.

Use 5 columns instead of 3 for the number of users since 3 is not quite
enough and there was space to spare.  This also fixes an off-by-2 error
in a previous fix forthe column count in the comment on STATROW.

Move all the pager fields 1 to the right so that the "count" and "pages"
descriptors more clearly apply to the pager fields and not the memory
fields.  There was space to space.

Waste some of the spare space at the right of the pager fields to expand
all the pager field widths to their old values (but now with a column
between the fields).  There are fields more in need of expansion but most
of them are not in places near spare space.
2006-02-14 13:27:25 +00:00
Bruce Evans
cd8ad406ad Removed the frobbing of CPU percentages from > 99.9 to 99.9. Rev.1.35
made it unnecessary.  (Rev.1.6 had to reduce the field width to 4, and
changed 100.0 and preposterous larger values down to 99.9 since 100.0
wouldn't have fitted.  Rev.1.35 handles precentages > 99.9 well enough by
changing the format to %.0f when the string given by the initial format
is too wide.)

Even with this change, during short testing I've never seen a percentage
of 100 being displayed by systat -v, although top(1) displays percentages
of 100 user or 100 idle for similar loads.
2006-02-14 12:26:51 +00:00
Bruce Evans
4bb97cfa93 Fix some minor bugs:
Always use snprintf()'s return value, since discarding it is a style
bug at best and using it here gives slightly simpler code and better
error checking.  Use snprintf() in putlongdouble() the same as in
putfloat().  (1.25 changed most sprintf()'s to snprintf()'s to fix
non-bugs without changing the logic to use the result of snprintf();
1.27 restored one of the sprintf()s by cloning a stale version of
putfloat().)

Don't print a too-long field in the unlikely case that the fallback
to M units in putint() leaves the field still too long.  (The fallback
to printing stars was lost in rev.1.58 when the fallback to M units
was added.)
2006-02-14 11:57:02 +00:00
Bruce Evans
991d33c312 Reduce the field width by 1 for many numeric fields so that most fields
cannot run into other fields or field descriptors.  If the value is
too large to fit in the field width, then the output format is adjusted
so that the value (usually) fits, but with fields running together
externally this adjustment usually didn't help.  Mostly it doesn't
matter to lose 1 digit of precision, but switching the output format
is bad if it happens often or gives bogus units.  The loss of width
is most serious for fields near "Csw" (which are also the ones which
must often ran together) since these have a high variance and large
values relative to the possible field widths so the switch occurs more
often now, and for the memory size fields where the switch gives the
bogus units kKB or MKB.

Now only the fields for r, p, d, s and w can run into each other.
These fields have width 3, and 3 cannot be reduced to 2 without losing
all precision when the value is between 100 and 999.

Trim "pdwake" to "pdwak" at think time now that it doesn't get clobbered
at runtime.  The manpage doesn't need to be changed for this because
it documents the clobbered descriptor, unlike for 4 other too-long
descriptors which only get clobbered if there are lots of interrupt
sources.

Trim "% busy" to "%busy" since most other descriptors for percentages
are spelled without the space and this change makes changing the widths
of the %busy fields unnecessary.
2006-02-14 10:47:36 +00:00
Bruce Evans
e3c53cce47 Oops, the "excessive" {} removed in the previous commit was needed
around PUTRATE() because PUTRATE() only looked like a function -- it was
multiple statements.  Use "do {...} while(0)" as usual in PUTRATE() so
that it is a single statement that can be used like a function.
2006-02-14 09:33:51 +00:00
Bruce Evans
123fa09901 Fixed all (?) bitrot in the comments about the number of columns used by
various groups of fields.
2006-02-14 08:33:02 +00:00
Bruce Evans
dc8ccdf0dc Fix all (?) cases where the field width of a numeric field was far too
large.  In most cases it is still 1 too large, so fields tend to run
together, but in the following cases it was more than 1 too large, and
the starting column was too small too, so the field started inside the
previous field or descriptor and clobbered that:
- "wire": the number for this overwrote 2 characters of the number for
  "Flt".  Reduce the field width by 3 (2 to avoid the overwrite and 1
  so that the fields don't run together).  This was already done for
  the preceding number for "cow".
- "inact": the number for this overwrote 1 character of the descriptor
  "Idle".  Reducing the field width by 2 is enough.
- "cache:" the number for this overwrote 3 characters of the scale
  "...|    |".  The field width should be reduced by 4 to keep things
  from running together, but that is a lot and not so necessary here
  since the final "|" in the scale serves as a delimiter.  Only reduce
  it by 3.
- "free": the number for this overwrote 2 characters of the bar graph.
  The character position under the final "|" in the scale is apparently
  not used, so reducing the field width by 3 is enough.

When "zfod" is in the main vmstat display:
- use the normal field width of 9 (not 5) for it since there is no shortage
  of space.  Fix style bugs (excessive {}) in the statement that
  conditionally writes it.

Write all reduced field widths for vmstat fields as "9 - <reduction>" as
a hint that we don't want to reduce them.
2006-02-14 07:44:21 +00:00
Bruce Evans
10a84fd9f7 Fixed style bugs in rev.1.12. Rev.1.12 arranged to display the interrupt
number in more cases by stealing 2 characters from the count field to
give more space in the descriptor field, but it did the column adjustments
for this strangely using an off-by-2 error in the base column and
compensating off-by-2 errors in 6 offsets from the base column (4 new
errors and 2 from not changing the offsets that actually changed).

Print the "Interrupts" header directly at its offset from the base column
instead of spacing it half using the offset and half by printing a space
character.
2006-02-14 05:37:25 +00:00
Paul Saab
043da612df Fix an overflow when calculating the number of kilobytes from the
number of pages.

Obtained from:	Yahoo!
2005-02-21 14:35:00 +00:00
Poul-Henning Kamp
84b4ac514e Use 'k' as suffix for Kilo
Pointed out by:	several.
2003-10-24 21:23:47 +00:00
Poul-Henning Kamp
f46a0535ef When a numeric field overflows its width, try formatting the number in
'kilo' or 'mega' with appropriate suffix instead of filling the field
with stars.
2003-10-20 20:13:50 +00:00
Poul-Henning Kamp
1e3f260a6b Let libdevstat calculate the device-busy % instead of home-rolling. 2003-04-09 07:49:43 +00:00
Poul-Henning Kamp
7194d335cf Run a revision of the devstat interface:
Kernel:

Change statistics to use the *uptime() timescale (ie: relative to
boottime) rather than the UTC aligned timescale.  This makes the
device statistics code oblivious to clock steps.

Change timestamps to bintime format, they are cheaper.

Remove the "busy_count", and replace it with two counter fields:
"start_count" and "end_count", which are updated in the down and
up paths respectively.  This removes the locking constraint on
devstat.

Add a timestamp argument to devstat_start_transaction(), this will
normally be a timestamp set by the *_bio() function in bp->bio_t0.
Use this field to calculate duration of I/O operations.

Add two timestamp arguments to devstat_end_transaction(), one is
the current time, a NULL pointer means "take timestamp yourself",
the other is the timestamp of when this transaction started (see
above).

Change calculation of busy_time to operate on "the salami principle":
Only when we are idle, which we can determine by the start+end
counts being identical, do we update the "busy_from" field in the
down path.  In the up path we accumulate the timeslice in busy_time
and update busy_from.

Change the byte_* and num_* fields into two arrays: bytes[] and
operations[].

Userland:

Change the misleading "busy_time" name to be called "snap_time" and
make the time long double since that is what most users need anyway,
fill it using clock_gettime(CLOCK_MONOTONIC) to put it on the same
timescale as the kernel fields.

Change devstat_compute_etime() to operate on struct bintime.

Remove the version 2 legacy interface: the change to bintime makes
compatibility far too expensive.

Fix a bug in systat's "vm" page where boot relative busy times would
be bogus.

Bump __FreeBSD_version to 500107

Review & Collaboration by:	ken
2003-03-15 21:59:06 +00:00
Poul-Henning Kamp
3bd41074f4 Add #include <sys/resource.h> 2003-02-16 15:46:25 +00:00
Poul-Henning Kamp
f341ca9891 Remove #include <sys/dkstat.h> 2003-02-16 14:13:23 +00:00
Matthew Dillon
f7550ecf3f Make 'sysctl vm.vmtotal' work properly using updated patch from Hiten.
(the patch in the PR was stale).

PR:             kern/5689
Submitted by:   Hiten Pandya <hiten@unixdaemons.com>
2003-01-11 07:29:47 +00:00
Dag-Erling Smørgrav
a5426997a3 debug.{numvnodes,freevnodes} moved to vfs. 2002-06-06 23:01:50 +00:00
Warner Losh
3f330d7d1a remove __P 2002-03-22 01:42:45 +00:00
Mark Murray
9ff712b0f5 WARNS=2 fixes with NO_WERROR set, as there are some header issues
with namelists. use __FBSDID().
2001-12-12 00:13:37 +00:00
Mark Murray
4b0ef38df3 Remove the 'irq' string from the irqN part of the "interrupts" display.
This allows us to see the irq number when device names ate too long.
2001-12-01 17:41:37 +00:00
Kenneth D. Merry
8f29de8be3 Convert systat(1) to use the new devstat interface.
Submitted by:	"Sergey A. Osokin" <osa@freebsd.org.ru>
2001-09-06 04:06:12 +00:00
Thomas Moestl
d62de5c4bb Replace a use of the hw.nintr sysctl as it has just gone away, cast
size_t variables when passing them to a printf-like function, and some
minor cleanups.
2001-06-01 13:29:19 +00:00