function::get_loadavg_index - Linux
Overview
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.
Syntax
function::get_loadavg_index ( INDEX )
Parameters:
- 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.
Options/Flags
None.
Examples
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.
Integration
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 averagessar
: Provides detailed system activity reportsvmstat
: Reports virtual memory activity