To an idea of CPU load average, I’m using uptime in a ksh script:
uptime | awk '{print $11}' | sed '$s/.$//' | read CPU
where I then use the variable CPU later.
The $11 part is to isolate the last five minutes part. But, I noticed today that this was not working. Specifically, the last five minutes part was returned with $9. The function is returning less parameters. This is because the machine was recently rebooted, and so uptime shows minutes since reboot instead of days and minutes.
Is there a way I can consistently get only the last five minutes part of uptime?
Try to split away the text before “Load Average”, and then use
awkon the remaining part.