History log of /openbsd-current/usr.bin/kstat/kstat.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.14 26-Mar-2024 dlg

print amps and watts


Revision tags: OPENBSD_7_5_BASE
# 1.13 16-Nov-2023 dlg

avoid reading data when enumerating kstats.

this means we can reliably read the provider/instance/name/unit
tuple, which should avoid "duplicate kstat entry" when multiple
kstat read handlers have issues.

found on a box with multiple rge interfaces, which have hardware
backed kstats that can only be read when the interface is up.


# 1.12 16-Nov-2023 dlg

handle printing cpu freq and volt kstat_kv types


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.11 10-Jul-2022 kn

s/0/instance/ in usage to match manual synopsis

OK jmc


# 1.10 05-May-2022 cheloha

kstat(1): implement wait with setitimer(2) instead of nanosleep(2)

kstat(1)'s wait period drifts because nanosleep(2) uses a relative
timeout. If we use setitimer(2)/sigsuspend(2) the period does not
drift.

While here, bump the upper bound for wait up to UINT_MAX and switch to
the normal strtonum(3) error message format.

With input from kn@.

Tweaked by bluhm@ to block SIGALRM with sigprocmask(2) while we're
outside of sigsuspend(2).

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

Earlier version ok millert@.

ok bluhm@


# 1.9 22-Apr-2022 dlg

handle 16 bit kstat_kv types


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.8 25-Jan-2021 dlg

fix filtering on kstat unit numbers


# 1.7 29-Dec-2020 dlg

fflush after outputting a set of stats.

this helps when you're trying to pipe stuff into other programs
(like awk and ttyplot).


Revision tags: OPENBSD_6_8_BASE
# 1.6 13-Aug-2020 schwarze

new kstat(1) manual page, using info from dlg@, from his commit messages,
and from partial code inspection;
OK dlg@


# 1.5 11-Aug-2020 dlg

add -w so kstat can update and print stats at a specified wait interval.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.


# 1.13 16-Nov-2023 dlg

avoid reading data when enumerating kstats.

this means we can reliably read the provider/instance/name/unit
tuple, which should avoid "duplicate kstat entry" when multiple
kstat read handlers have issues.

found on a box with multiple rge interfaces, which have hardware
backed kstats that can only be read when the interface is up.


# 1.12 16-Nov-2023 dlg

handle printing cpu freq and volt kstat_kv types


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.11 10-Jul-2022 kn

s/0/instance/ in usage to match manual synopsis

OK jmc


# 1.10 05-May-2022 cheloha

kstat(1): implement wait with setitimer(2) instead of nanosleep(2)

kstat(1)'s wait period drifts because nanosleep(2) uses a relative
timeout. If we use setitimer(2)/sigsuspend(2) the period does not
drift.

While here, bump the upper bound for wait up to UINT_MAX and switch to
the normal strtonum(3) error message format.

With input from kn@.

Tweaked by bluhm@ to block SIGALRM with sigprocmask(2) while we're
outside of sigsuspend(2).

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

Earlier version ok millert@.

ok bluhm@


# 1.9 22-Apr-2022 dlg

handle 16 bit kstat_kv types


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.8 25-Jan-2021 dlg

fix filtering on kstat unit numbers


# 1.7 29-Dec-2020 dlg

fflush after outputting a set of stats.

this helps when you're trying to pipe stuff into other programs
(like awk and ttyplot).


Revision tags: OPENBSD_6_8_BASE
# 1.6 13-Aug-2020 schwarze

new kstat(1) manual page, using info from dlg@, from his commit messages,
and from partial code inspection;
OK dlg@


# 1.5 11-Aug-2020 dlg

add -w so kstat can update and print stats at a specified wait interval.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.


# 1.11 10-Jul-2022 kn

s/0/instance/ in usage to match manual synopsis

OK jmc


# 1.10 05-May-2022 cheloha

kstat(1): implement wait with setitimer(2) instead of nanosleep(2)

kstat(1)'s wait period drifts because nanosleep(2) uses a relative
timeout. If we use setitimer(2)/sigsuspend(2) the period does not
drift.

While here, bump the upper bound for wait up to UINT_MAX and switch to
the normal strtonum(3) error message format.

With input from kn@.

Tweaked by bluhm@ to block SIGALRM with sigprocmask(2) while we're
outside of sigsuspend(2).

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

Earlier version ok millert@.

ok bluhm@


# 1.9 22-Apr-2022 dlg

handle 16 bit kstat_kv types


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.8 25-Jan-2021 dlg

fix filtering on kstat unit numbers


# 1.7 29-Dec-2020 dlg

fflush after outputting a set of stats.

this helps when you're trying to pipe stuff into other programs
(like awk and ttyplot).


Revision tags: OPENBSD_6_8_BASE
# 1.6 13-Aug-2020 schwarze

new kstat(1) manual page, using info from dlg@, from his commit messages,
and from partial code inspection;
OK dlg@


# 1.5 11-Aug-2020 dlg

add -w so kstat can update and print stats at a specified wait interval.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.


# 1.10 05-May-2022 cheloha

kstat(1): implement wait with setitimer(2) instead of nanosleep(2)

kstat(1)'s wait period drifts because nanosleep(2) uses a relative
timeout. If we use setitimer(2)/sigsuspend(2) the period does not
drift.

While here, bump the upper bound for wait up to UINT_MAX and switch to
the normal strtonum(3) error message format.

With input from kn@.

Tweaked by bluhm@ to block SIGALRM with sigprocmask(2) while we're
outside of sigsuspend(2).

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

Earlier version ok millert@.

ok bluhm@


# 1.9 22-Apr-2022 dlg

handle 16 bit kstat_kv types


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.8 25-Jan-2021 dlg

fix filtering on kstat unit numbers


# 1.7 29-Dec-2020 dlg

fflush after outputting a set of stats.

this helps when you're trying to pipe stuff into other programs
(like awk and ttyplot).


Revision tags: OPENBSD_6_8_BASE
# 1.6 13-Aug-2020 schwarze

new kstat(1) manual page, using info from dlg@, from his commit messages,
and from partial code inspection;
OK dlg@


# 1.5 11-Aug-2020 dlg

add -w so kstat can update and print stats at a specified wait interval.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.


# 1.9 22-Apr-2022 dlg

handle 16 bit kstat_kv types


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.8 25-Jan-2021 dlg

fix filtering on kstat unit numbers


# 1.7 29-Dec-2020 dlg

fflush after outputting a set of stats.

this helps when you're trying to pipe stuff into other programs
(like awk and ttyplot).


Revision tags: OPENBSD_6_8_BASE
# 1.6 13-Aug-2020 schwarze

new kstat(1) manual page, using info from dlg@, from his commit messages,
and from partial code inspection;
OK dlg@


# 1.5 11-Aug-2020 dlg

add -w so kstat can update and print stats at a specified wait interval.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.


# 1.8 25-Jan-2021 dlg

fix filtering on kstat unit numbers


# 1.7 29-Dec-2020 dlg

fflush after outputting a set of stats.

this helps when you're trying to pipe stuff into other programs
(like awk and ttyplot).


Revision tags: OPENBSD_6_8_BASE
# 1.6 13-Aug-2020 schwarze

new kstat(1) manual page, using info from dlg@, from his commit messages,
and from partial code inspection;
OK dlg@


# 1.5 11-Aug-2020 dlg

add -w so kstat can update and print stats at a specified wait interval.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.


# 1.7 29-Dec-2020 dlg

fflush after outputting a set of stats.

this helps when you're trying to pipe stuff into other programs
(like awk and ttyplot).


Revision tags: OPENBSD_6_8_BASE
# 1.6 13-Aug-2020 schwarze

new kstat(1) manual page, using info from dlg@, from his commit messages,
and from partial code inspection;
OK dlg@


# 1.5 11-Aug-2020 dlg

add -w so kstat can update and print stats at a specified wait interval.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.


# 1.6 13-Aug-2020 schwarze

new kstat(1) manual page, using info from dlg@, from his commit messages,
and from partial code inspection;
OK dlg@


# 1.5 11-Aug-2020 dlg

add -w so kstat can update and print stats at a specified wait interval.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.


# 1.5 11-Aug-2020 dlg

add -w so kstat can update and print stats at a specified wait interval.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.


# 1.4 10-Aug-2020 dlg

sigh, i made the previous diff to small.

main needs to understand the kstat_tree type now, so move the
declaration up.


# 1.3 10-Aug-2020 dlg

factor out the printing of kstats. no functional change otherwise.


# 1.2 10-Aug-2020 dlg

add the ability to filter which kstats are displayed.

kstats are identified by a "provider:instance:name:unit" tuple,
where provider and name are strings, and instance and unit are
integers. you can pass tuples as arguments to kstat to select them
for display, eg, to see the rxq and txq stats for the first rings
on an em0 interface, you can run `kstat em0:0:rxq:0 em0:0:txq:0`.

this can be pretty tedious if you want to select a group of stats
quickly though, so there's some wildcard and pattern matching support.

firstly, empty fields in the tuple are wildcarded, eg, if you want
to see all the stats that an mcx0 interface provides then run
`kstat mcx0:::`.

secondly, strings in a tuple (ie, the provider and name fields) are
compared using fnmatch(3) so you can use shell like patterns to
match fields. to expand the last example to all mcx interfaces, you
can run `kstat mcx*:::`.

lastly, you can pass a bare name to match on all kstats with that
name. eg, to see the txq stats for all interfaces, just run
`kstat txq`.


# 1.1 06-Jul-2020 dlg

add kstat(8), the userland side of kstat(4).

this currently just dumps all the kstats it can find and prints out
their current values. in the future i want to be able to pass what
kstats im intersted in as arguments, and tell it to poll stats and
show rates instead of current values when appropriate.