Current Issue


Table of contents

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 12.0

Version 12.0 delivers every issue of Sys Admin from 1992 through 2006 and every
issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!

Sys Admin Magazine > Archives > 1992 > 9203
Article Figure 1 Figure 2 Figure 3 Figure 4 Listing 1 Listing 2

Listing 3: The sysload.sh Script

1: #
2: # sysload.sh: log system load
3: #             (called from cron table)
4: #
5: # Written by Leor Zolman, 6/17/91
6: #
7: # usage:
8: #   sysload.sh daily    (run periodically throughout the day)
9: #   sysload.sh final    (run once at the end of the day)
10: #
11: # When $1 is "daily": adds a line to DAYLOG with the current 15-minute
12: #   load average.
13: #
14: # When $1 is "final": computes average of all daily entries in DAYLOG. An
15: #   entry noting this average is appended to AVGLOG. The contents of DAYLOG
16: #   and the average are then appended  to LOADLOG,  and DAYLOG is deleted.
17: #   Then, if this is Friday, the average of the 5 daily averages is
18: #   also computed and appended to AVGLOG.
19: #
20: #
21:
22: debug=N
23: ADMINGRP=tech           # System administration group id on your system
24:
25: if [ $debug = N ]; then
26:     DAYLOG=/u3/General/Ltmp/sysload.day
27:     LOADLOG=/u3/General/Ltmp/sysload.log
28:     AVGLOG=/u3/General/Ltmp/sysload.avg
29: else
30:     DAYLOG=day
31:     LOADLOG=log
32:     AVGLOG=avg
33: fi
34:
35: [ $# -ne 1 ] && echo "usage: $0 {daily | final}" >&2 && exit 1
36:
37: case $1 in
38:     daily)
39:         if [ ! -r $DAYLOG ]; then
40:             touch $DAYLOG
41:             chmod 664 $DAYLOG
42:             chgrp $ADMINGRP $DAYLOG
43:         fi
44:         echo `date +"%a %D %T"`: `uptime |
45:         awk '{
46:             txt = $(NR)
47:             if (substr(txt, length(txt), length(txt)) == ",")
48:                 txt = substr(txt, 1, length(txt)-1)
49:             print txt
50:         }'` >>$DAYLOG
51:         break;;
52:
53:     final)
54:         [ ! -r $DAYLOG ] && echo "$0: Cannot open $DAYLOG" >&2
&& exit 1
55:         if [ ! -r $LOADLOG ]; then
56:             touch $LOADLOG
57:             chmod 664 $LOADLOG
58:             chgrp $ADMINGRP $LOADLOG
59:         fi
60:         if [ ! -r $AVGLOG ]; then
61:             touch $AVGLOG
62:             chmod 664 $AVGLOG
63:             chgrp $ADMINGRP $AVGLOG
64:         fi
65:         tmp=`tmpname sld`
66:         echo "`date +\"%a %D\"`: \c" >$tmp
67:         awk '{
68:             total = total + $4
69:             count = count + 1
70:             }
71:             END {
72:                 printf("\tAverage for the day: %5.2

				  



MarketPlace

Instant Answers to Your IT & Business Questions
Sign Up & Get Full Access To The Definitive Online Book Collection With SkillSoft's Books24x7�.

NEW! Numara FootPrints 9 - Service Desk Management
IT Service Management that Delivers. Real Value. Real Flexibility. Real Results. Free Demo.

Online Crash Analysis
Automatically capture customer crash data, no debugger required. Support for .NET, C++, OS X, Java.

Visit Dell� Small and Medium Business Online Store
One Stop to Buy All Your Business IT Solutions. Browse Through Dell's Best Deals Online Now!

Wanna see your ad here?