cross clmn

Monday 2 May 2016

Shell script to Generate Table skew Report on IBM Netezza System(nz_skew).

#Shell script to Generate Table skew  Report  on IBM Netezza System(nz_skew).
#Manish Jaiswal
#!/bin/sh
# =============================================================================
# Netezza Table Skew script
# =============================================================================
# Script configuration - Static values only.
# =============================================================================
cd /export/home/nz
. ~/.bashrc
export PATH=/nz/kit/bin:/nz/kit/sbin:/nz/kit/bin/adm:/bin:/usr/bin:/usr/local/bin:.:/nz/support/bin
export email_list="NZGreen@gmail.com,EDW_Support@gmail.com"
#export email_list="manish.jaiswal@gmail.com"
export SCRIPTOUTPUTDIR=/export/home/nz/scripts/MONITOR
export VIPHOSTNAME=EDW-NTZ-001-LQC
export SCRIPTSTART=$(date -d "$1" +"%Y%m%d")
export NZSUPPORT7207BINDIR=/nz/support-IBM_Netezza-7.2.0.7.P1-160122-1638/bin
export RPT_FILE="${SCRIPTOUTPUTDIR}/${VIPHOSTNAME}.skew.${SCRIPTSTART}.txt"
find $SCRIPTOUTPUTDIR/*txt  -mtime +5 -exec rm {} \;

# -----------------------------------------------------------------------------
# Run the nz_skew command and generate report.
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Start the checks.
# -----------------------------------------------------------------------------
echo "Starting table skew check for ${VIPHOSTNAME}"

${NZSUPPORT7207BINDIR}/nz_skew -sort size | grep -v "^ [DPQ]MISC"   > ${RPT_FILE} 2>&1

RetCode=$?

# Check the outcome.
if [ ${RetCode} -eq 0 ]
then
        echo "Successful."
else
        echo "FAILED!"
echo  "Table skew check report generation failure! [${VIPHOSTNAME}]" |mailx -s "Notification:Table skew check report generation failure! [${VIPHOSTNAME}]" $email_list
exit;
fi

echo "Finished table skew check for ${VIPHOSTNAME}"
# -----------------------------------------------------------------------------
# Distribute the table skew check report.
# -----------------------------------------------------------------------------
echo "Distributing table skew report for ${VIPHOSTNAME}"

echo  "Netezza Table Skew Report for  ${VIPHOSTNAME}" |mailx -s "Netezza Table Skew Report for  ${VIPHOSTNAME} " -a ${RPT_FILE} $email_list

# =============================================================================
# Script Completion
# =============================================================================

No comments:

Post a Comment