If you want to use the load average in your Perl-Script you could use this Bash snippets, The load average returns the summary of the last 1,5 and 15 minutes.
This returns the last minute :
uptime | awk '{print $10}' | cut -d "," -f 1,2 | tr "," "."
How it works : uptime returns all 3 loads, I print with awk the number 10 in the array.then the result is “3,45,” … I remove the last comma with cut and then translate all commas to dots with tr to convert it to a number in Perl.
if you want the last 5 minutest you have to change it to :
awk ‘{print $11}’
and for the last 15minutes to :
awk ‘{print $12}’
to check your result run :
uptime;uptime | awk '{print $10}' | cut -d "," -f 1,2 | tr "," "."
result :
12:11:35 up 7 days, 20:20, 2 users, load average: 0,29, 0,35, 0,40
0.29
seems fine.