Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track number of context switches in system metrics snapshots #4244

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/performance/stat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ def get_forks(metrics)
metrics[:cpu]['processes'][0]
end

def get_context_switches(metrics)
metrics[:cpu]['ctxt'][0]
end

def get_network(metrics)
net = metrics[:net]
{
Expand Down Expand Up @@ -221,11 +225,12 @@ def get_disks(metrics)

def host_to_internal(metrics)
{
:cpu_util => get_cpu_util(metrics),
:fork => get_forks(metrics),
:network => get_network(metrics),
:swap => get_swap(metrics),
:disk => get_disks(metrics)
:cpu_util => get_cpu_util(metrics),
:context_switches => get_context_switches(metrics),
:fork => get_forks(metrics),
:network => get_network(metrics),
:swap => get_swap(metrics),
:disk => get_disks(metrics)
}
end

Expand Down Expand Up @@ -332,6 +337,7 @@ def printable_result(params={})
if filter.include? :sys
rb.open_group('System')
rb.single_metric('CPU utilization', m[:cpu_util] * 100.0, :suffix => '%')
rb.avg_metric('Number of context switches', m[:context_switches])
rb.avg_metric('Number of forks done', m[:fork])
rb.avg_metric('Pages swapped out', m[:swap][:swapped_out], :warn_if_exceeding => 0)
rb.avg_metric('Pages swapped in', m[:swap][:swapped_in], :warn_if_exceeding => 0)
Expand Down