function::get_loadavg_index - Linux


function::get_loadavg_index retrieves the load average for the Linux system at the specified index. The load average is a measure of the system’s overall CPU utilization over a given period of time.


function::get_loadavg_index ( INDEX )


  • INDEX: The index of the load average to retrieve. Valid values are 1, 5, and 15, representing the load average over the last minute, 5 minutes, and 15 minutes, respectively.




Simple example:

Retrieve the 1-minute load average:

load_avg_1min=$(function::get_loadavg_index 1)

Complex example:

Retrieve all three load averages and print them in a comma-separated list:

load_avg_1min=$(function::get_loadavg_index 1)
load_avg_5min=$(function::get_loadavg_index 5)
load_avg_15min=$(function::get_loadavg_index 15)

echo "$load_avg_1min, $load_avg_5min, $load_avg_15min"

Common Issues

  • Invalid index: If an invalid index is provided, the command will fail with an error message.


function::get_loadavg_index can be combined with other commands for advanced tasks, such as:

  • Monitoring system performance using scripts
  • Building custom monitoring dashboards
  • Triggering actions based on load average thresholds

Related Commands

  • uptime: Displays system uptime and load averages
  • sar: Provides detailed system activity reports
  • vmstat: Reports virtual memory activity