Skip to content

Instantly share code, notes, and snippets.

@rahulinux
Created September 2, 2013 15:18
Show Gist options
  • Save rahulinux/6413978 to your computer and use it in GitHub Desktop.
Save rahulinux/6413978 to your computer and use it in GitHub Desktop.
check load average of server and return if load more than 6 or passed threshold to the function
CheckLoadadv() {
# Set threshold value
local Threshold=$1
# if threshold not specify then take deafault 6
(( $Threshold )) || Threshold=6
# get input values from /proc/loadavg file
local Current_loadadv="$(cut -d" " -f1 /proc/loadavg )"
# take first value from inputdata
local Cur_int_loadadv="${Current_loadadv/.*}"
if (( $Cur_int_loadadv >= $Threshold )); then
return 1
else
return 0
fi
}
CheckLoadadv $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment