Skip to content
Daniel Berger edited this page Apr 28, 2023 · 3 revisions

The sys-proctable also comes with a Sys::Top class. It contains a single class method, top. By default this will return an array of the top 10 processes using the pctcpu (percent CPU) field.

Synopsis

# Use the defaults
Sys::Top.top

# Return the top 5 processes only
Sys::Top.top(5)

# Return the top 5 processes using the `rss` field
Sys::Top.top(5, :rss)

Mac and AIX

By default, MacOS and AIX will use the pid number instead of pctcpu. You can, of course, alter this behavior by specifying the field you would like to use as the second argument to the top method.

Clone this wiki locally