Cover V03, I02
Article
Figure 1
Listing 1
Listing 2

mar94.tar


Listing 2: Monthly script to collect errors for the month and store them in compressed format

# Get the hard/software errors from last month and store them
# in directory /var/adm/errors/error.<mon>.Z
# Exit if the monthly report has already been generated (file exists)
# This script must be executed as root, since the
# error log file /var/adm/ras/errlog is owned by root

# Get current month and year
mon="`/bin/date +%m`"
year="`/bin/date +%y`"

# Script invoked by cron at the beginning of the next month. So change
# the month to the last month
if ["$mon" -eq 1]
then
mon=12
year="`/bin/expr year - 1`"
else
mon="`/bin/expr mon - 1`"
fi

# Make month a 2 digit number

[$mon -lt 10] && mon="0${mon}"

# File to store the report.
file="/var/adm/errors/errors.$mon.Z"

# Exit if already run. Script is invoked the first 5 days every month.
if [-s "$file"]
then
# Check if file has been created last year
# If the time field contains a colon, it displays the time
# (hh:mm), the file was recently created.
# Otherwise the file has been created
# last year and can be overwritten.
set -- `ls -l $file`

[`expr $8 ':' ' [0-9][0-9]:[0-9][0-9]'`-eq 5] && exit 1
fi

# Get all entries of month <mon>.
/usr/bin/errpt -s ${mon}010000${year} -e ${mon}312359${year} |
/usr/bin/compress > file

# Remove previous month entries from the error log file.
/usr/bin/errclear `/bin/date +%d`