Re: Script for paging
2002-08-25 08:16:41
This script requires an external program, like qpage, to actually page you, but
the script works very well. Watch for lines that have wrapped around in my
pasting.
Miles
#!/usr/bin/ksh
#
# Name: TSM Server Log Page
#
# Purpose:
# Scan the TSM Error log file for new errors
# If it doesn't exist, create a control file
#
# Date: Dec 2000
#
# Required Parameters:
# -------------------------------------------------------------------------
# None
#
# Optional Parameters:
# -------------------------------------------------------------------------
# None
#
# Change History:
#
# Date Name Comments
# _________________________________________________________________________
#
WORK_DIR=${WORK_DIR:=/tmp}
UNIX_SYSTEM_DIRECTORY=${UNIX_SYSTEM_DIRECTORY:=/home/unxsa}
SCRDIR=$UNIX_SYSTEM_DIRECTORY/bin
CONTROL_FILE=.adsmlog
if [[ ! -f ~/$CONTROL_FILE ]]
then
echo "010900002001" >~/$CONTROL_FILE
fi
# Read the date from the control file
cat ~/$CONTROL_FILE | read TIME
MONTH=`echo $TIME | cut -c -2`
DAY=`echo $TIME | cut -c 3-4`
HOUR=`echo $TIME | cut -c 5-6`
MINUTE=`echo $TIME | cut -c 7-8`
YEAR=`echo $TIME | cut -c 9-12`
NEWTIME="$DAY/$MONTH/$YEAR $HOUR:$MINUTE"
# List errors from the control date forward
# 24 may 2002 purdym change ANR to AN[ER]
dsmadmc -id=query -password=query q actlog begind="$MONTH/$DAY/$YEAR"
begint="$HOUR:$MINUTE" >/tmp/$CONTROL_FILE.$$
if [[ -f /tmp/$CONTROL_FILE.$$.2 ]]
then
rm /tmp/$CONTROL_FILE.$$.2
fi
# join lines from q actlog
cat /tmp/$CONTROL_FILE.$$| while read LINE
do
if [[ `echo $LINE | grep -c "[0-9][0-9]/[0-9][0-9]/[0-9][0-9][
]*[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"` -gt 0 ]]
then
echo "\n${LINE}\c" >>/tmp/$CONTROL_FILE.$$.2
else
echo "$LINE\c" >>/tmp/$CONTROL_FILE.$$.2
fi
done
# format output
# grep - find all errors
# sed replace - with nothing
# sed s/[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9] - remove date
# sed "s/ / /g" - consolidate blank space
# sed "s/^/\-\>/g" - add a '->' to the begging of each error
cat /tmp/$CONTROL_FILE.$$.2 | grep "^.*AN[ER][0-9][0-9][0-9][0-9]E" | sed "s/-/
/g" | sed "s/[ ]*[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][ ]*//" | sed "s/ / /g" |
sed "s/
/ /g" | sed "s/^/\-\>/g" >/tmp/$CONTROL_FILE.$$
echo $(date +%m%d%H%M%Y)
>~/$CONTROL_FILE
echo "TSM Errors since $NEWTIME"
>/tmp/adsm.$$
# ANR2034E QUERY EVENT: No match found using this criteria.
# ANR0944E QUERY PROCESS: No active processes found
# ANR8827E No Entry/Exit port is available on library
# ANR2165E QUERY ACTLOG: Invalid begin date
# ANR2000E Unknown Command
# ANR8807W
# ANR2305E no such command
# ANR2904E
# ANR2020E invlaid parameter
# ANE4037E File changed during processing
# ANE4987E The file is in use by another process
#
#
# remove common messages that really aren't errors
cat /tmp/$CONTROL_FILE.$$ | grep -viE
"ANR2305E|ANR8827E|ANR2034E|ANR0944E|ANR2165E|ANR2000E|query|ANR2939E|ANR2904E|ANR2020E|ANE4037E|ANE4987E"
>/tmp/adsm1.$$
if [[ -s /tmp/adsm1.$$ ]]
then
cat /tmp/adsm.$$ /tmp/adsm1.$$ >/tmp/adsm2.$$
cat /tmp/adsm2.$$
cat /tmp/adsm2.$$ | /usr/local/bin/qpage -P Miles
fi
rm /tmp/$CONTROL_FILE.$$* 2>/dev/null
rm /tmp/adsm?.$$ 2>/dev/null
rm /tmp/adsm.$$ 2>/dev/null
exit 0
----------------------------------------------------------------------------------------------
Miles Purdy
System Manager
Agriculture and Agri-Food Canada,
Information Systems Team,
Farm Income Programs Directorate
Winnipeg, MB, CA
purdym AT fipd.gc DOT ca
ph: (204) 984-1602 fax: (204) 983-7557
"If you hold a UNIX shell up to your ear, can you hear the C?"
-------------------------------------------------------------------------------------------------
>>> Jbaechi AT CSCC DOT EDU 23-Aug-02 3:50:54 PM >>>
Hi, Experts,
Anybody can send me a sample script that makes the server (AIX) page me
when getting certain server log messages? Pleaseeeeeee? I/O error from
tape library brought the server down several time last week. Thanks as
always.
Jin Bae Chi (Gus)
Data Center
614-287-2496
614-287-5488 Fax
e-mail: jbaechi AT cscc DOT edu
|
|
|