Listing 1: The load Script
1: #
2: # load: Display system load, with suggestions as to how appropriate a
3: # time it is to run a CPU-intensive process.
4: #
5:
6: echo
7: echo " SYSTEM LOAD ANALYSIS"
8: echo
9:
10: uptime | awk '{
11: val = $(NF - 2)
12:
13: if (substr(val, length(val), length(val)) == ",")
14: val = substr(val, 1, length(val)-1)
15:
16: printf "The current system load is %s\n\n", val
17:
18: if (val < 1) {
19: print "This is a very light system load."
20: print "It is a good time to run a report."
21: }
22: else if (val < 1.5) {
23: print "This is a relatively light system load. It is OK to run"
24: print "a report now."
25: } else if (val < 2) {
26: print "This is a moderate system load. Long reports will slow"
27: print "the system down a bit, but go ahead if you must."
28: print "Better yet, for low-priority reports, wait until the"
29: print "system load drops below 1.00."
30: } else if (val < 3) {
31: print "This is a medium-to-heavy load. Please do not run long reports"
32: print "unless you really have to. They WILL slow the system down somewhat."
33: } else if (val < 4) {
34: print "This is a heavy load. Please do not run reports unless they are"
35: print "very urgent."
36: } else if (val < 5) {
37: print "This is an EXTREMELY HEAVY system load. Please defer running any"
38: print "reports at least until the load drops down under 3.00,"
39: print "preferably under 2.00. Thank you."
40: }
41: else if (val < 7) {
42: print "At this rate, the CPU may soon have a meltdown..."
43: print "Please, PLEASE do NOT run any reports until the load"
44: print "settles down below 3.00 !! THANK YOU!"
45: }
46: else {
47: print "This is a ridiculously heavy load; there may be"
48: print "something wrong with the system. Please contact a Tech"
49: print "person immediately, and, of course, do not run any reports."
50: }
51: }'
|