#!/bin/sh
#
# load:	Display system load, with suggestions as to how appropriate a
#		time it is to run a CPU-intensive process.
#

echo
echo "     SYSTEM LOAD ANALYSIS"
echo

uptime | awk '{
	val = $(NF - 2)

	if (substr(val, length(val), length(val)) == ",")
		val = substr(val, 1, length(val)-1)

	printf "The current system load is %s\n\n", val

	if (val < 1) {
		print "This is a very light system load."
		print "It is a good time to run a report."
	}
	else if (val < 1.5) {
		print "This is a relatively light system load. It is OK to run"
		print "a report now."
	} else if (val < 2) {
		print "This is a moderate system load. Long reports will slow"
		print "the system down a bit, but go ahead if you must."
		print "Better yet, for low-priority reports, wait until the"
		print "system load drops below 1.00."
	} else if (val < 3) {
		print "This is a medium-to-heavy load. Please do not run long reports"
		print "unless you really have to. They WILL slow the system down somewhat."
	} else if (val < 4) {
		print "This is a heavy load. Please do not run reports unless they are"
		print "very urgent."
	} else if (val < 5) {
		print "This is an EXTREMELY HEAVY system load. Please defer running any"
		print "reports at least until the load drops down under 3.00,"
		print "preferably under 2.00. Thank you."
	}
	else if (val < 7) {
		print "At this rate, the CPU may soon have a meltdown..."
		print "Please, PLEASE do NOT run any reports until the load"
		print "settles down below 3.00 !! THANK YOU!"
	}
	else {
		print "This is a ridiculously heavy load; there may be"
		print "something wrong with the system. Please contact a Tech"
		print "person immediately, and, of course, do not run any reports."
	} 
}'
