History log of /openbsd-current/usr.bin/systat/main.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.77 04-Dec-2022 cheloha

systat(1): vmstat: measure elapsed time with clock_gettime(2) instead of ticks

The vmstat view in systat(1) should not use statclock() ticks to count
elapsed time. First, ticks are low resolution. Second, the statclock
is sometimes randomized, so each tick is not necessarily of equal
length. Third, we're counting ticks from every CPU on the system, so
every rate in the view is divided by the number of CPUs. For example,
on an amd64 system with 8 CPUs you currently see:

200 clock

... when the true clock interrupt rate on that system is 1600.

Instead, measure elapsed time with clock_gettime(2). Use CLOCK_UPTIME
here so we exclude time when the system is suspended. With this
change we no longer need "stathz" or "hertz". We can also get rid of
the anachronistic secondary clock failure test.

Prompted by dlg@ and jmatthew@. deraadt@ says this has been in snaps
since 2022-11-21; no complaints.

Link: https://marc.info/?l=openbsd-tech&m=166898960831136&w=2

ok dlg@ deraadt@


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.76 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.75 02-Jul-2021 millert

Use nanosleep() and setitimer() instead of usleep() and ualarm().
Both usleep() and ualarm() are obsolete and were removed from POSIX.
OK deraadt@


# 1.74 02-Jun-2021 martijn

Make the hints at the bottom row sticky by turning the knobs toggles.
Specifically this effects ^G, help and order.

While here also document the 'h' character.

Initial inspiration and diff from Anindya Mukherjee (anindya49 <at> hotmail
<dot> com)

OK bluhm@


Revision tags: OPENBSD_6_9_BASE
# 1.73 30-Jan-2021 martijn

Fix delay parsing by stealing from strtonum and returning a proper error to
the user when an invalid value is entered instead of silently falling back
to the default 5s.

While here I also capped the upper limit to UINT32_MAX / 1000000 to prevent
useconds_t overflow. This hard limits us to 4294s, instead of the current
soft limit which just make systat go berserk if you go over it.

Reported and original diff by Nick Gasson nick <at> nickg <dot> me <dot> uk

OK cheloha@
Tweaks and OK bluhm@


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.72 12-Jan-2020 martijn

Add support for human readable numbers where applicable.

OK stsp@ and bluhm@


# 1.71 14-Oct-2019 deraadt

pledge() won't work but we can use unveil() to reduce filesystem access
in these 3 related programs (they borrow parts of each other using .PATH)
Hopefully no regressions, ktrace checks by myself and mestre


Revision tags: OPENBSD_6_6_BASE
# 1.70 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_5_BASE
# 1.69 17-Jan-2019 tedu

use $OpenBSD markers
ok millert mpi


Revision tags: OPENBSD_6_4_BASE
# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.76 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.75 02-Jul-2021 millert

Use nanosleep() and setitimer() instead of usleep() and ualarm().
Both usleep() and ualarm() are obsolete and were removed from POSIX.
OK deraadt@


# 1.74 02-Jun-2021 martijn

Make the hints at the bottom row sticky by turning the knobs toggles.
Specifically this effects ^G, help and order.

While here also document the 'h' character.

Initial inspiration and diff from Anindya Mukherjee (anindya49 <at> hotmail
<dot> com)

OK bluhm@


Revision tags: OPENBSD_6_9_BASE
# 1.73 30-Jan-2021 martijn

Fix delay parsing by stealing from strtonum and returning a proper error to
the user when an invalid value is entered instead of silently falling back
to the default 5s.

While here I also capped the upper limit to UINT32_MAX / 1000000 to prevent
useconds_t overflow. This hard limits us to 4294s, instead of the current
soft limit which just make systat go berserk if you go over it.

Reported and original diff by Nick Gasson nick <at> nickg <dot> me <dot> uk

OK cheloha@
Tweaks and OK bluhm@


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.72 12-Jan-2020 martijn

Add support for human readable numbers where applicable.

OK stsp@ and bluhm@


# 1.71 14-Oct-2019 deraadt

pledge() won't work but we can use unveil() to reduce filesystem access
in these 3 related programs (they borrow parts of each other using .PATH)
Hopefully no regressions, ktrace checks by myself and mestre


Revision tags: OPENBSD_6_6_BASE
# 1.70 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_5_BASE
# 1.69 17-Jan-2019 tedu

use $OpenBSD markers
ok millert mpi


Revision tags: OPENBSD_6_4_BASE
# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.75 02-Jul-2021 millert

Use nanosleep() and setitimer() instead of usleep() and ualarm().
Both usleep() and ualarm() are obsolete and were removed from POSIX.
OK deraadt@


# 1.74 02-Jun-2021 martijn

Make the hints at the bottom row sticky by turning the knobs toggles.
Specifically this effects ^G, help and order.

While here also document the 'h' character.

Initial inspiration and diff from Anindya Mukherjee (anindya49 <at> hotmail
<dot> com)

OK bluhm@


Revision tags: OPENBSD_6_9_BASE
# 1.73 30-Jan-2021 martijn

Fix delay parsing by stealing from strtonum and returning a proper error to
the user when an invalid value is entered instead of silently falling back
to the default 5s.

While here I also capped the upper limit to UINT32_MAX / 1000000 to prevent
useconds_t overflow. This hard limits us to 4294s, instead of the current
soft limit which just make systat go berserk if you go over it.

Reported and original diff by Nick Gasson nick <at> nickg <dot> me <dot> uk

OK cheloha@
Tweaks and OK bluhm@


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.72 12-Jan-2020 martijn

Add support for human readable numbers where applicable.

OK stsp@ and bluhm@


# 1.71 14-Oct-2019 deraadt

pledge() won't work but we can use unveil() to reduce filesystem access
in these 3 related programs (they borrow parts of each other using .PATH)
Hopefully no regressions, ktrace checks by myself and mestre


Revision tags: OPENBSD_6_6_BASE
# 1.70 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_5_BASE
# 1.69 17-Jan-2019 tedu

use $OpenBSD markers
ok millert mpi


Revision tags: OPENBSD_6_4_BASE
# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.74 02-Jun-2021 martijn

Make the hints at the bottom row sticky by turning the knobs toggles.
Specifically this effects ^G, help and order.

While here also document the 'h' character.

Initial inspiration and diff from Anindya Mukherjee (anindya49 <at> hotmail
<dot> com)

OK bluhm@


Revision tags: OPENBSD_6_9_BASE
# 1.73 30-Jan-2021 martijn

Fix delay parsing by stealing from strtonum and returning a proper error to
the user when an invalid value is entered instead of silently falling back
to the default 5s.

While here I also capped the upper limit to UINT32_MAX / 1000000 to prevent
useconds_t overflow. This hard limits us to 4294s, instead of the current
soft limit which just make systat go berserk if you go over it.

Reported and original diff by Nick Gasson nick <at> nickg <dot> me <dot> uk

OK cheloha@
Tweaks and OK bluhm@


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.72 12-Jan-2020 martijn

Add support for human readable numbers where applicable.

OK stsp@ and bluhm@


# 1.71 14-Oct-2019 deraadt

pledge() won't work but we can use unveil() to reduce filesystem access
in these 3 related programs (they borrow parts of each other using .PATH)
Hopefully no regressions, ktrace checks by myself and mestre


Revision tags: OPENBSD_6_6_BASE
# 1.70 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_5_BASE
# 1.69 17-Jan-2019 tedu

use $OpenBSD markers
ok millert mpi


Revision tags: OPENBSD_6_4_BASE
# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.73 30-Jan-2021 martijn

Fix delay parsing by stealing from strtonum and returning a proper error to
the user when an invalid value is entered instead of silently falling back
to the default 5s.

While here I also capped the upper limit to UINT32_MAX / 1000000 to prevent
useconds_t overflow. This hard limits us to 4294s, instead of the current
soft limit which just make systat go berserk if you go over it.

Reported and original diff by Nick Gasson nick <at> nickg <dot> me <dot> uk

OK cheloha@
Tweaks and OK bluhm@


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.72 12-Jan-2020 martijn

Add support for human readable numbers where applicable.

OK stsp@ and bluhm@


# 1.71 14-Oct-2019 deraadt

pledge() won't work but we can use unveil() to reduce filesystem access
in these 3 related programs (they borrow parts of each other using .PATH)
Hopefully no regressions, ktrace checks by myself and mestre


Revision tags: OPENBSD_6_6_BASE
# 1.70 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_5_BASE
# 1.69 17-Jan-2019 tedu

use $OpenBSD markers
ok millert mpi


Revision tags: OPENBSD_6_4_BASE
# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.72 12-Jan-2020 martijn

Add support for human readable numbers where applicable.

OK stsp@ and bluhm@


# 1.71 14-Oct-2019 deraadt

pledge() won't work but we can use unveil() to reduce filesystem access
in these 3 related programs (they borrow parts of each other using .PATH)
Hopefully no regressions, ktrace checks by myself and mestre


Revision tags: OPENBSD_6_6_BASE
# 1.70 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_5_BASE
# 1.69 17-Jan-2019 tedu

use $OpenBSD markers
ok millert mpi


Revision tags: OPENBSD_6_4_BASE
# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.71 14-Oct-2019 deraadt

pledge() won't work but we can use unveil() to reduce filesystem access
in these 3 related programs (they borrow parts of each other using .PATH)
Hopefully no regressions, ktrace checks by myself and mestre


Revision tags: OPENBSD_6_6_BASE
# 1.70 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_5_BASE
# 1.69 17-Jan-2019 tedu

use $OpenBSD markers
ok millert mpi


Revision tags: OPENBSD_6_4_BASE
# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.70 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_5_BASE
# 1.69 17-Jan-2019 tedu

use $OpenBSD markers
ok millert mpi


Revision tags: OPENBSD_6_4_BASE
# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.69 17-Jan-2019 tedu

use $OpenBSD markers
ok millert mpi


Revision tags: OPENBSD_6_4_BASE
# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.68 30-May-2018 krw

Add uvm view to show all values being collected in uvmexp.

Feedbacks, tweaks, ok bluhm@


Revision tags: OPENBSD_6_3_BASE
# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.67 08-Feb-2018 martijn

Add the order keyword to systat global command interpreter.
This command shows the available orderings for the current view, which
ordering is active, their shortcuts, and if they're in reverse order.

manpage nits jmc@
OK tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.66 13-Oct-2016 otto

tweak previous; hostname is alredy available plus some better formatting
in case line numbers and/or PAUSED is shown; ok tedu@


# 1.65 13-Oct-2016 tedu

add the hostname to the display. started by otto, then deraadt. ok deraadt


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.64 02-Jan-2016 benno

garbage collect unsused variable
found by evh -AT- riseup -DOT- net, ok florian@


Revision tags: OPENBSD_5_8_BASE
# 1.63 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


# 1.62 12-Mar-2015 claudio

Switch the netstat view of systat to use the same kvm_getfiles()
function similar to netstat(1). The output still shows the same
info but may be a bit differently sorted. Also it will now show
connections that are not UDP or TCP. This was the last bit of
systat that needed kvm access and so now systat no longer needs
to be setgid kmem.
With this commit OpenBSD is officially setgid kmem free and an
almost 10 year journey finally comes to an end.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 16-Jan-2015 deraadt

first batch of programs adapting to the namespace cleanup
(pfvar.h nameser.h proc.h ucred.h)
ok guenther millert, and some review from doug as well.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.60 07-Sep-2013 reyk

Add a new screen "cpu" that simply lists the usage of each CPU core.
Also add a new -B command line flag that works like -b but waits some
cycles before dumping anything to the console.

With much help from jmc@
OK jj@ lambert@ jmc@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.59 05-Apr-2011 mpf

Add support to display numbers with thousands separators
and to switch the ifstat view to Bits/s.
This allows us to see live network throughput in units
like MBit/s, which is more practical.
OK sthen@, manpage OK jmc@, "put it in" deraadt@


# 1.58 31-Mar-2011 lum

Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed.
ok nicm@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.57 16-Jul-2010 lum

Make the terminal checking capability of systat better.
Checks taken from top(1) screen.c/init_termcap()
ok canacar@ sthen@ nicm@


# 1.56 02-Jul-2010 lum

Allow systat to print date and time when in rawmode.
ok canacar@ millert@


Revision tags: OPENBSD_4_7_BASE
# 1.55 21-Jul-2009 sthen

Allow systat(1) to resolve names by adding a new -N flag. (The default was
changed some time ago). Noticed by landry@, discussed with canacar@ and others.
ok deraadt@


Revision tags: OPENBSD_4_6_BASE
# 1.54 25-Jun-2009 deraadt

the rule is not to use nitems() in userland yet


# 1.53 25-Jun-2009 okan

use the nitems() macro where appropriate

ok canacar@


# 1.52 19-Jun-2009 jasper

- add two new views to systat, 'nfsserver' and 'nfsclient'.
output is similar to nfsstat(1), but it allows for better monitoring/debugging

tricked into by and "i love this" thib@
ok canacar@


Revision tags: OPENBSD_4_5_BASE
# 1.51 08-Nov-2008 canacar

Add malloc and buckets views that display kernel malloc statistics similar
to vmstat -m


# 1.50 05-Nov-2008 canacar

Fix some function prototypes, remove unused variables and commented out code


# 1.49 04-Nov-2008 espie

spelling: ambigious -> ambiguous


# 1.48 02-Nov-2008 canacar

Add a view that displays pool(9) information. Idea and ok deraadt@


# 1.47 01-Nov-2008 canacar

Remove disabled help text code and -S command, both leftovers from pftop,
skip the correct number of bytes after the 'start' command.


# 1.46 31-Oct-2008 canacar

Implement start and stop commands as documented,
explicitly pass the command buffer to the command functions.


# 1.45 31-Oct-2008 canacar

make ^G display the current view and refresh interval as documented.


# 1.44 13-Aug-2008 jmc

-S currently does nothing useful, so remove it from
SYNOPSIS and usage(); after some discussion with canacar


# 1.43 08-Aug-2008 matthieu

Small step towards fixing documentation:
- sync usage() with reality. Remove the -h option that does nothing.
- don't complain about kvm_openfiles() error in case of incorrect usage.
- add basic descriptions of the new options and views in the manual
page. More is needed...
with help from jmc@ and sobrado@. ok sobrado@.


Revision tags: OPENBSD_4_4_BASE
# 1.42 31-Jul-2008 canacar

Do not allow negative or zero delay values from the command line,
use the same check as the -s option. Noticed by johan@


# 1.41 12-Jul-2008 canacar

Add ':q' as an alias to ':quit', to match old behaviour. Initial patch
from dlg@, this is a simpler version.


# 1.40 13-Jun-2008 deraadt

compile on older gcc; no decl after code


# 1.39 13-Jun-2008 canacar

Set 'naptime' which is used by the interface page in differential mode.
Also remove a debugging message while there.
reported by claudio@


# 1.38 12-Jun-2008 canacar

New display engine for systat, based on pftop. Adds new views for pf
(status, state, rule, queue). While all displays work, some keyboard
comands are not implemented yet. Other features include better handling
of display resize and scrolling for long views. Committing now to fix
the remaining issues in the tree.
Testing and comments by otto@ and harding@, ok deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.37 21-May-2007 cnst

fix -Wall warning about unused variable `errstr', which was introduced in the previous revision; ok deraadt, otto, tedu


# 1.36 24-Apr-2007 tedu

support non-integral refresh intervals, possibly as low as 0.1s.
this makes it more useful for real time display of fast changing stats
ok art deraadt


Revision tags: OPENBSD_4_1_BASE
# 1.35 25-Feb-2007 deraadt

use the 1 line load line from 'systat vm' on all the other displays, giving
them more room. much cleaner, and it is less code too; ok deanna


Revision tags: OPENBSD_4_0_BASE
# 1.34 09-May-2006 deraadt

delay time of 0 should be invalid; evol@online.ptt.ru


# 1.33 12-Apr-2006 ray

Improve error message.

Found by Florin Iamandi <florin dot i at tiscali dot it>.

OK tedu@ and deraadt@


# 1.32 31-Mar-2006 deraadt

fairly simple cleanup, lots of testing done


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.31 04-Jul-2005 djm

make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.30 26-Apr-2004 itojun

add -n flag (do not reverse-lookup). pb and deraadt ok


# 1.29 14-Apr-2004 deraadt

wakeup after ^Z did not continue redraws and such. use own ^Z handler.
ok otto millert


Revision tags: OPENBSD_3_5_BASE
# 1.28 17-Dec-2003 jmc

- add -w to options description
- document default refresh interval
- sync usage() with SYNOPSIS

inspired by PR 3608;
ok deraadt@


# 1.27 17-Dec-2003 deraadt

remove old -M and -N; 3608


Revision tags: OPENBSD_3_4_BASE
# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.25 04-Aug-2002 deraadt

kvm gid revocation earlier


# 1.24 18-Jun-2002 deraadt

revoke privs after kvm_openfiles


Revision tags: OPENBSD_3_1_BASE
# 1.23 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.22 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.21 07-Dec-2001 deraadt

move back. pvalchev -- the bug was quite obscure


# 1.20 07-Dec-2001 pvalchev

back out latest changes which cause problems on alpha/sparc64 until
they are fixed


# 1.19 28-Nov-2001 ericj

remove unused var


# 1.18 23-Nov-2001 deraadt

fix signal races. use sysctl() instead of kvm where possible, and then KNF
the hell out of it; checked by miod


# 1.17 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.16 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.15 04-May-2001 ericj

handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.14 04-Nov-1997 kstailey

simple SIGWINCH handler; deals only with window size changes >= 80x24


Revision tags: OPENBSD_2_2_BASE
# 1.13 25-Aug-1997 deraadt

when getting interrupt, clean up curses only if curses was active


# 1.12 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.11 23-Jun-1997 millert

Cleanup by Theo and myself. CMDLINE changed to long to make
command line work on 64bit platforms. This is somewhat bogus
and is really just a temporary workaround (there may be a curses bug).


# 1.10 16-Jun-1997 kstailey

You can't store a double in an int and then do tests for the fractional part
miss thing! Also, make more sensitive to digital decay. Now "<<<" will
show up in load average display.


Revision tags: OPENBSD_2_1_BASE
# 1.9 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.8 22-Dec-1996 tholo

Deal with _POSIX_SAVED_IDS when relinquishing privileges


Revision tags: OPENBSD_2_0_BASE
# 1.7 08-Aug-1996 niklas

Clarify usage printout


# 1.6 06-Aug-1996 deraadt

_POSIX2_LINE_MAX errbuf for kvm_openfiles()


# 1.5 06-Aug-1996 deraadt

avoid buf oflows


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 22-May-1996 deraadt

libutil


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision