Skip to main content
added 186 characters in body
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
set -- $(cat /proc/loadavg)
load=${2%2/.*/}
if [ "$load" -gtge 5500 ]; then
  echo alert
fi

Get the load average from /proc, and set the positional parameters based on those fields. Grab the 2nd field and strip off everything fromout the period to the end. If that (now numeric) value is greater than 5or equal to 500, alert. This assumes (the current) behavior where the load averages are presented to two decimal points. Thanks to Arrow for pointing out a better way.

set -- $(cat /proc/loadavg)
load=${2%.*}
if [ "$load" -gt 5 ]; then
  echo alert
fi

Get the load average from /proc, and set the positional parameters based on those fields. Grab the 2nd field and strip off everything from the period to the end. If that (now numeric) value is greater than 5, alert.

set -- $(cat /proc/loadavg)
load=${2/./}
if [ "$load" -ge 500 ]; then
  echo alert
fi

Get the load average from /proc, and set the positional parameters based on those fields. Grab the 2nd field and strip out the period. If that (now numeric) value is greater than or equal to 500, alert. This assumes (the current) behavior where the load averages are presented to two decimal points. Thanks to Arrow for pointing out a better way.

Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265

set -- $(cat /proc/loadavg)
load=${2%.*}
if [ "$load" -gt 5 ]; then
  echo alert
fi

Get the load average from /proc, and set the positional parameters based on those fields. Grab the 2nd field and strip off everything from the period to the end. If that (now numeric) value is greater than 5, alert.