#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
##
#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
##
Hello Manish,
ReplyDeleteI hope all is well with you.
Could you explain the each line of your script from beginning till the function part, please?
I having problem to run it on my server.
Could you please paste your error here ?
Delete