Skip to main content
Notice removed Canonical answer required by CommunityBot
Bounty Ended with no winning answer by CommunityBot
added 1 character in body
Source Link
Braiam
  • 36.9k
  • 29
  • 114
  • 176

In order to monitor the CPU usage in an AIX server I'm using the following script that is executed every 10 mins.

lparstat 2 10 > cpu
usage=$(tail -10 cpu | awk 'BEGIN {sum=0;} {sum+=$4} END{print int(100-sum/10)}')


if [[ $usage -ge 90 ]]; then
# mail the error and cpu file to admin
# displaying this for testing purposes
echo "CPU usage off the charts!!!"
cat cpu
fi

However, incasein case the CPU usage is above 90% I need to list the top 5 Processes that are using the CPU.

How do I achieve this?

In order to monitor the CPU usage in an AIX server I'm using the following script that is executed every 10 mins.

lparstat 2 10 > cpu
usage=$(tail -10 cpu | awk 'BEGIN {sum=0;} {sum+=$4} END{print int(100-sum/10)}')


if [[ $usage -ge 90 ]]; then
# mail the error and cpu file to admin
# displaying this for testing purposes
echo "CPU usage off the charts!!!"
cat cpu
fi

However, incase the CPU usage is above 90% I need to list the top 5 Processes that are using the CPU.

How do I achieve this?

In order to monitor the CPU usage in an AIX server I'm using the following script that is executed every 10 mins.

lparstat 2 10 > cpu
usage=$(tail -10 cpu | awk 'BEGIN {sum=0;} {sum+=$4} END{print int(100-sum/10)}')


if [[ $usage -ge 90 ]]; then
# mail the error and cpu file to admin
# displaying this for testing purposes
echo "CPU usage off the charts!!!"
cat cpu
fi

However, in case the CPU usage is above 90% I need to list the top 5 Processes that are using the CPU.

How do I achieve this?

Notice added Canonical answer required by Braiam
Bounty Started worth 50 reputation by Braiam
edited tags; edited tags
Link
Braiam
  • 36.9k
  • 29
  • 114
  • 176
added 88 characters in body
Source Link
debal
  • 3.8k
  • 5
  • 19
  • 18

In order to monitor the CPU usage in an AIX server I'm using the following script that is executed every 10 mins.

lparstat 2 10 > cpu
usage=$(tail -10 cpu | awk 'BEGIN {sum=0;} {sum+=$4} END{print int(100-sum/10)}')


if [[ $usage -ge 90 ]]; then
# mail the error and cpu file to admin
# displaying this for testing purposes
echo "CPU usage off the charts!!!"
cat cpu
fi

However, incase the CPU usage is above 90% I need to list the top 5 Processes that are using the CPU.

How do I achieve this?

In order to monitor the CPU usage in an AIX server I'm using the following script that is executed every 10 mins.

lparstat 2 10 > cpu
usage=$(tail -10 cpu | awk 'BEGIN {sum=0;} {sum+=$4} END{print int(100-sum/10)}')


if [[ $usage -ge 90 ]]; then
echo "CPU usage off the charts!!!"
cat cpu
fi

However, incase the CPU usage is above 90% I need to list the top 5 Processes that are using the CPU.

How do I achieve this?

In order to monitor the CPU usage in an AIX server I'm using the following script that is executed every 10 mins.

lparstat 2 10 > cpu
usage=$(tail -10 cpu | awk 'BEGIN {sum=0;} {sum+=$4} END{print int(100-sum/10)}')


if [[ $usage -ge 90 ]]; then
# mail the error and cpu file to admin
# displaying this for testing purposes
echo "CPU usage off the charts!!!"
cat cpu
fi

However, incase the CPU usage is above 90% I need to list the top 5 Processes that are using the CPU.

How do I achieve this?

Source Link
debal
  • 3.8k
  • 5
  • 19
  • 18
Loading