Wednesday, September 14, 2016

Shell Scripts to Generate Statistics on IBM Netezza System ( nz_genstats) GENERATE EXPRESS STATISTICS

#Shell Scripts to Generate Statistics on IBM Netezza System ( nz_genstats) GENERATE EXPRESS #STATISTICS
#Manish Jaiswal
#!/bin/sh
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
### Database List needed to be analyzed
DB_LIST=$(nzsql -l |awk ' NR > 3'|sed '$d' |awk '{ print $1 }'|sed '$d')
##############
DBA_email="EDW_Support@gmail.com"
DAY=`date '+%a'`
LOG_DIR=/export/home/nz/scripts/log
LOG=$LOG_DIR/analyzed_`hostname`_`date +%y%m%d%H%M%S`.log
###Delete 15 days old log
find $LOG_DIR/*.log  -type f -mtime +15 -exec rm -f {} \; 2> /dev/null
##############################
###Main Function
analyze_db_fn()
{
### Genrate Gather stats  for $DAY listed databses
  for i in `echo $DB_LIST`
           do
           echo "Starting Gather stats of Database $i on `date +%y%m%d%H%M%S` " >> $LOG
   nz_genstats ${i} >> $LOG
   if [ $? -eq 0 ]; then
   echo "Succeeed GENERATE EXPRESS STATISTICS of database $i on `date +%y%m%d%H%M%S` " >> $LOG
   else
   echo "Failure GENERATE EXPRESS STATISTICS of database $i on `date +%y%m%d%H%M%S` " >> $LOG
   fi
   done
echo " Please find GENERATE STATISTICS Report in attachment for `hostname`"| mailx -s " Gather Stats  Report for Netezza $DAY `hostname` server on `date +%y%m%d%H%M%S` " -a $LOG "$DBA_email"
}
##############################
##Call Funtion to Genrate stats
analyze_db_fn
##

1 comment:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in NETEZZA TRAINING, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Sangita Mohanty
    MaxMunus
    E-mail: sangita@maxmunus.com
    Skype id: training_maxmunus
    Ph:(0) 9738075708 / 080 - 41103383
    http://www.maxmunus.com/

    ReplyDelete