Skip to content

Adds MacOS-specfic ps aux command. #90

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

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions scripts/cpu_percentage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ print_cpu_percentage() {
usage="$(cached_eval WMIC cpu get LoadPercentage | grep -Eo '^[0-9]+')"
# shellcheck disable=SC2059
printf "$cpu_percentage_format" "$usage"
else
if is_osx; then
load=$(cached_eval ps aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}')
cpus=$(cpus_number)
echo "$load $cpus" | awk -v format="$cpu_percentage_format" '{printf format, $1/$2}'
else
load=$(cached_eval ps -aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think actually we can drop the -

Suggested change
else
if is_osx; then
load=$(cached_eval ps aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}')
cpus=$(cpus_number)
echo "$load $cpus" | awk -v format="$cpu_percentage_format" '{printf format, $1/$2}'
else
load=$(cached_eval ps -aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}')
else
load=$(cached_eval ps aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}')

cpus=$(cpus_number)
Expand Down