Scott

many thanks for your help. i'll let you know how I get on ...

all the best

Leslie

-----Original Message-----
From: McLeod, Scott [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 05, 2001 9:29 PM
To: [EMAIL PROTECTED]
Subject: RE: DB2EUG: USEREXIT Shell Script Sample for AIX anybody?


This is the sample AIX Korn shell script I promised to a few people
yesterday.  Its a lot better than the default IBM one.  I included code to
createa log file of my archiving process so I could monitor its status.  The
file is placed into the same directory as the DB2DIAG file.  The only thing
hard coded is the location to move the files to and you can easily change
that.




#!/bin/ksh
############################################################################
####
#
# Usage:  db2uexit
#
# Description: This script migrates active log files to the archive logs
# directory.  It is invoked by DB2 automatically when a log full condition
# occurs.
#
# Parameters: See the IBM manual for information.
#
############################################################################
####
############################################################################
####
# Run the profile of the DB2 subsystem that invokes the exit
############################################################################
####
MYHOME="/db2_6000/`whoami`"
. $MYHOME/.profile > /dev/null 2>&1

############################################################################
####
# Set a path for a log file that contains info on archiving.
############################################################################
####
DIAGPATH="`db2 get dbm cfg | grep DIAGPATH |  cut -c60-100`"
DIAGLEVEL="`db2 get dbm cfg | grep DIAGLEVEL | cut -c60-90`"
AUDIT_LOG=true
AUDIT_LOG_FILE="$DIAGPATH/db2uexit.log"
AUDIT_LOG_FILE="/db2_6000/db2p/sqllib/db2dump/db2uexit.log"

if [ "$AUDIT_LOG" = true ];then
   echo "***************************************************************"
>> $AUDIT_LOG_FILE
   echo "Userexit begins at `date`"  >> $AUDIT_LOG_FILE
   echo "DIAGLEVEL=$DIAGLEVEL,DIAGPATH=$DIAGPATH" >> $AUDIT_LOG_FILE
fi
#---------------------------------------------------------------------------
---#
#--  Test the number of parms passed and the format of them.
--#
#---------------------------------------------------------------------------
---#
if [ $# -ne 4 ];then
   if [ "$AUDIT_LOG" = true ];then
      echo "Incorrect number of parms passed to Userexit program" >>
$AUDIT_LOG_FILE
      echo "Number of parms passed was $#"  >> $AUDIT_LOG_FILE
   fi
   exit 20
fi

if [ "$1" = ARCHIVE ];then
   continue
else
   if [ "$1" = RETRIEVE ];then
      continue
   else
      if [ "$AUDIT_LOG" = true ];then
         echo "Unsupported function requested from Userexit program" >>
$AUDIT_LOG_FILE
         echo "Function requested was $1"  >> $AUDIT_LOG_FILE
      fi
      echo
"***************************************************************\n"  >>
$AUDIT_LOG_FILE
      exit 20
   fi
fi

#---------------------------------------------------------------------------
---#
#--  ARCHIVE requests will copy file from activelogs to archivelogs
#---------------------------------------------------------------------------
---#
if [ "$1" = ARCHIVE ];then
 
#---------------------------------------------------------------------------
#
   #-- Audit the request
--#
 
#---------------------------------------------------------------------------
#
   if [ "$AUDIT_LOG" = true ];then
      echo "`date` DB2UEXIT AUDIT LOG ENTRY" >> $AUDIT_LOG_FILE
      echo "Request to $1 file $4 from $3" >> $AUDIT_LOG_FILE
   fi
 
#---------------------------------------------------------------------------
#
   #-- Copy the file to archivelogs
--#
 
#---------------------------------------------------------------------------
#
   LCDBNAME="`echo $2 | tr 'A-Z' 'a-z'`"
   echo "cp $3$4 $MYHOME/archivelogs/$LCDBNAME" >> $AUDIT_LOG_FILE
   cp $3$4 $MYHOME/archivelogs/$LCDBNAME >> $AUDIT_LOG_FILE 2>&1
   UNIXRC=$?
   if [ "$UNIXRC" -ne 0 ];then
      STANDRC=$STANDRC_28
      if [ "$AUDIT_LOG" = true ];then
         echo "cp Command Failed with RC:$UNIXRC" >> $AUDIT_LOG_FILE
      fi
      echo
"***************************************************************\n"  >>
$AUDIT_LOG_FILE
      exit 28
   fi
 
#---------------------------------------------------------------------------
#
   #-- Audit the request
--#
 
#---------------------------------------------------------------------------
#
   if [ "$AUDIT_LOG" = true ];then
      echo "Request to $1 file $4 from $3 was successful" >> $AUDIT_LOG_FILE
   fi
fi

#---------------------------------------------------------------------------
---#
#--  RETRIEVE requests will cp a file from archivelogs to activelogs
#---------------------------------------------------------------------------
---#
if [ "$1" = RETRIEVE ];then
 
#---------------------------------------------------------------------------
#
   #-- Audit the request
--#
 
#---------------------------------------------------------------------------
#
   if [ "$AUDIT_LOG" = true ];then
      echo "Request to $1 file $4 to $3" >> $AUDIT_LOG_FILE
   fi
 
#---------------------------------------------------------------------------
#
   #-- Copy the file
 
#---------------------------------------------------------------------------
#
   LCDBNAME="`echo $2 | tr 'A-Z' 'a-z'`"
   echo "cp $MYHOME/archivelogs/$LCDBNAME/$4 $3" >> $AUDIT_LOG_FILE
   cp $MYHOME/archivelogs/$LCDBNAME/$4 $3 >> $AUDIT_LOG_FILE 2>&1
   UNIXRC=$?
   if [ "$UNIXRC" -ne 0 ];then
      if [ "$AUDIT_LOG" = true ];then
         echo "cp Command Failed with RC:$UNIXRC" >> $AUDIT_LOG_FILE
         echo " "                            >> $AUDIT_LOG_FILE
      fi
      echo
"***************************************************************\n"  >>
$AUDIT_LOG_FILE
      exit 28
   fi
 
#---------------------------------------------------------------------------
#
   #-- Audit the request
--#
 
#---------------------------------------------------------------------------
#
   if [ "$AUDIT_LOG" = true ];then
      echo "Request to $1 file $4 to $3 was successful" >> $AUDIT_LOG_FILE
   fi
fi

if [ "$AUDIT_LOG" = true ];then
   echo "Userexit ends at `date`"  >> $AUDIT_LOG_FILE
   echo "***************************************************************\n"
>> $AUDIT_LOG_FILE
fi



-----Original Message-----
From: Pendlebury-Bowe, Leslie
[mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 12:28 PM
To: [EMAIL PROTECTED]
Subject: RE: DB2EUG: USEREXIT Shell Script Sample for AIX anybody?


Scott

good to speak to you again .. 

Korn Shell .. thx

Les

-----Original Message-----
From: McLeod, Scott [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 3:56 PM
To: [EMAIL PROTECTED]
Subject: RE: DB2EUG: USEREXIT Shell Script Sample for AIX anybody?


I have several tucked away at home I can send you.  Are you looking for a
korn shell version or a C routine?  

> -----Original Message-----
> From: Pendlebury-Bowe, Leslie [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, June 04, 2001 5:34 AM
> To:   [EMAIL PROTECTED]
> Subject:      DB2EUG: USEREXIT Shell Script Sample for AIX anybody?
> 
> Hi all,
> 
> anybody have an example shell script USEREXIT for AIX(also nice if it has
> an
> example of calling the ADSM Api Client - but not totally essential).?
> 
> Many thanks
> 
> Leslie
> 
> 
> 
> **********************************************************************
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed.
> Sony cannot accept liability for statements made which are clearly
> the sender's own and not made on behalf of Sony.
> (01)
> **********************************************************************
> 
> =====
> To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
> For other info (and scripts), see
> http://people.mn.mediaone.net/scottrmcleod

=====
To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
For other info (and scripts), see http://people.mn.mediaone.net/scottrmcleod

=====
To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
For other info (and scripts), see http://people.mn.mediaone.net/scottrmcleod

=====
To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
For other info (and scripts), see http://people.mn.mediaone.net/scottrmcleod

=====
To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
For other info (and scripts), see http://people.mn.mediaone.net/scottrmcleod

Reply via email to