ustat(8)

๐Ÿ“ฆ version 0.36.1, in alpine 3.24, nixpkgs unstable, opensuse-leap 16.0

๐ŸŽ€ USTAT(8) ๐ŸŽ€ System Manager's Manual

โœจ NAME โœจ

ustat, javastat, nodestat, perlstat, phpstat, pythonstat, rubystat, tclstat โ€” activity stats from high-level languages ๐Ÿ’–

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

javastat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS]
[-d] [interval [count]]
nodestat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS]
[-d] [interval [count]]
perlstat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS]
[-d] [interval [count]]
phpstat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d]
[interval [count]]
pythonstat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS]
[-d] [interval [count]]
rubystat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS]
[-d] [interval [count]]
tclstat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d]
[interval [count]]
ustat [-l {java,node,perl,php,python,ruby,tcl}] [-C] [-S
{cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval
[count]]

๐Ÿ’… DESCRIPTION ๐Ÿ’…

okay so this is basically "top" but for high-level language events ๐Ÿ”ฅ we're talking garbage collections, exceptions, thread creations, object allocations, method calls, and more, bestie. ๐Ÿ˜ญ The events get aggregated for each process and printed in a top-like table, which you can sort by different fields. Heads up though: not every language runtime gives you the same set of details ๐Ÿ’€

This uses in-kernel eBPF maps to store per-process summaries, which is so efficient it's giving ๐Ÿงš

This tool relies on USDT probes embedded in a bunch of high-level languages, like Java, Node, Perl, PHP, Python, Ruby, and Tcl โœจ It needs a runtime that's instrumented with these probes. In some cases that means building from source with a USDT-specific flag, like --enable-dtrace or --with-dtrace. For Java, some probes aren't enabled by default, but you can turn them on by running the Java process with the -XX:+ExtendedDTraceProbes flag. For PHP processes, the environment variable USE_ZEND_DTRACE must be set to 1. ๐ŸŒธ

Newly-created processes only get traced at the next interval. If you run this with a short interval (say, 1-5 seconds), it should be virtually unnoticeable ๐Ÿซถ For longer intervals, you might miss processes that started and terminated during the interval window ๐Ÿ™ˆ

Since this uses BPF, only the root user can use this tool. Not me being strict, it's just the rule ๐Ÿ‘‘


๐Ÿงš REQUIREMENTS ๐Ÿงš

CONFIG_BPF and bcc.

๐ŸŒˆ OPTIONS ๐ŸŒˆ

  • -l {java,node,perl,php,python,ruby,tcl} โ€” the language you want to trace. By default, all languages get traced ๐Ÿ’œ
  • -C โ€” don't clear the screen between updates ๐Ÿ“
  • -S {cload,excp,gc,method,objnew,thread} โ€” sort the output by the field you pick ๐Ÿ’…
  • -r MAXROWS โ€” don't print more than this many rows ๐ŸŽ€
  • -d โ€” prints the resulting BPF program, for debugging purposes ๐Ÿ”ฅ
  • interval โ€” the gap between updates, in seconds โญ
  • count โ€” how many interval summaries you get ๐Ÿฆ‹

๐Ÿ“ EXAMPLES ๐Ÿ“

Summarize activity in high-level languages, 1 second refresh:

# ustat

Don't clear the screen, and only show the top 8 rows:

# ustat -Cr 8

5 second summaries, 10 times only:

# ustat 5 10

๐Ÿ”ฎ FIELDS ๐Ÿ”ฎ

  • loadavg โ€” the contents of /proc/loadavg โœจ
  • PID โ€” process ID ๐Ÿ†”
  • CMDLINE โ€” the process command line. Honestly the second and following arguments often give you a hint as to which application is being run ๐Ÿ‘€
  • METHOD/s โ€” count of method invocations during the interval ๐Ÿ’œ
  • GC/s โ€” count of garbage collections during the interval ๐Ÿ—‘๏ธ
  • OBJNEW/s โ€” count of objects allocated during the interval ๐ŸŒธ
  • CLOAD/s โ€” count of classes loaded during the interval ๐Ÿ“ฆ
  • EXC/s โ€” count of exceptions thrown during the interval ๐Ÿ’€
  • THR/s โ€” count of threads created during the interval ๐Ÿงต

๐Ÿซง OVERHEAD ๐Ÿซง

โš ๏ธ Real talk: when you use this with high-frequency events, like method calls, you can expect a very significant slow-down ๐Ÿ˜ญ

That said, a lot of the high-level languages covered here already have a pretty high per-method invocation cost, especially in interpreted mode, so it's not all on this tool ๐Ÿ™ˆ For the lower-frequency events, like garbage collections or thread creations, the overhead should not be significant ๐Ÿ’– Specifically, when probing Java processes without the -XX:+ExtendedDTraceProbes flag, the most expensive probes aren't emitted, so the overhead should be acceptable โœจ

๐ŸŒ SOURCE ๐ŸŒ

This is from bcc. ๐Ÿ

https://github.com/iovisor/bcc

Also look in the bcc distribution for a companion _example.txt file containing example usage, output, and commentary for this tool ๐Ÿ“š

๐Ÿ’ป OS ๐Ÿ’ป

Linux ๐Ÿง

๐Ÿงช STABILITY ๐Ÿงช

Unstable - in development. ๐Ÿšง

๐Ÿ‘ฉโ€๐Ÿ’ป AUTHOR ๐Ÿ‘ฉโ€๐Ÿ’ป

Sasha Goldshtein ๐Ÿ‘‘

๐Ÿ”— SEE ALSO ๐Ÿ”—

trace(8), argdist(8), tplist(8) ๐Ÿ’œ


Okay bestie, that's the whole page! ๐Ÿ’– It's the ustat(8) manual from the USER COMMANDS section, dated 2018-10-09 ๐ŸŽ€ Now go trace some garbage collections and slay your way through your Unix era ๐Ÿ˜ญโœจ๐Ÿซถ