Skip to content

Commit

Permalink
Fix memory report when over 1GB
Browse files Browse the repository at this point in the history
  • Loading branch information
rjwills28 committed Sep 27, 2023
1 parent 64ed019 commit dec6946
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions performance/cpu_monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,26 @@ if [ $SAMPLE == true ]; then
$1+0>0 {++COUNT
TOTAL=TOTAL+$9
if (COUNT % 10 == 0) {
printf "%s %s: Average CPU Usage: %d%%, Memory usage: %d MiB\n", \
strftime("%Y-%m-%d"), time, TOTAL/COUNT, $6/1000
if ($6 < 1000) {
printf "%s %s: Average CPU Usage: %d%%, Memory usage: %.2f GiB\n", \
strftime("%Y-%m-%d"), time, TOTAL/COUNT, $6
} else {
printf "%s %s: Average CPU Usage: %d%%, Memory usage: %d MiB\n", \
strftime("%Y-%m-%d"), time, TOTAL/COUNT, $6/1000
}
TOTAL=0
COUNT=0
}
}'
else
top -b -d 2 -p $PID | awk -v pid="$PID" '
/^top -/{time = $3}
$1+0>0 {printf "%s %s: CPU Usage: %d%%, Memory usage: %d MiB\n", \
strftime("%Y-%m-%d"), time, $9, $6/1000
}'
$1+0>0 {if ($6 < 1000) {
printf "%s %s: CPU Usage: %d%%, Memory usage: %.2f GiB\n", \
strftime("%Y-%m-%d"), time, $9, $6
} else {
printf "%s %s: CPU Usage: %d%%, Memory usage: %d MiB\n", \
strftime("%Y-%m-%d"), time, $9, $6/1000
}
}'
fi

0 comments on commit dec6946

Please sign in to comment.