#shell script to Monitor Disk on Netezza IBM system disk_monitor
#Manish Jaiswal
#!/bin/sh
# =============================================================================
# Netezza Disk Monitor Template
# =============================================================================
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
email_list="NZRed@gmail.com,EDW_Support@gmail.com"
SCRIPTOUTPUTDIR=/export/home/nz/scripts/MONITOR
VIPHOSTNAME=EDW-NTZ-001-LQC
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}.DiskMonitor.${SCRIPTSTART}.txt"
export CLEAN_RPT_FILE="${SCRIPTOUTPUTDIR}/${VIPHOSTNAME}.DiskMonitor.${SCRIPTSTART}.clean.txt"
export ACTIONS_FILE="${SCRIPTOUTPUTDIR}/${VIPHOSTNAME}.DiskMonitor.${SCRIPTSTART}.actions.txt"
find $SCRIPTOUTPUTDIR/*txt -mtime +5 -exec rm {} \;
# -----------------------------------------------------------------------------
# Start the disk checks.
# -----------------------------------------------------------------------------
echo "Starting disk monitor for ${VIPHOSTNAME}"
#/nz/support-IBM_Netezza-7.2.0.7.P1-160122-1638/bin/adm/disk_monitor \
${NZSUPPORT7207BINDIR}/adm/disk_monitor > ${RPT_FILE} 2>&1
RetCode=$?
# Check the outcome.
if [ ${RetCode} -eq 0 ]
then
echo "Successful."
else
echo "FAILED!"
echo "Disk monitor report generation failure! [${VIPHOSTNAME}]" |mailx -s "Notification:Disk monitor report generation failure! [${VIPHOSTNAME}]" $email_list
fi
echo "Finished disk monitor for ${VIPHOSTNAME}"
# -----------------------------------------------------------------------------
# Check for actionable items and alert as needed.
# -----------------------------------------------------------------------------
echo "Checking ${VIPHOSTNAME} disk monitor report for actionable items"
# Strip the stderr output from the report.
sed -ne '/^[A-Z]/d;p' "${RPT_FILE}" | sed -e '/Fewer lines on second insert/d' > ${CLEAN_RPT_FILE}
# Extract the actionable portion of the report.
sed -n '/Actionable/,/^(/p' ${CLEAN_RPT_FILE} > ${ACTIONS_FILE}
# Get the number of actionable items.
ActionableItems=`grep "^(" ${ACTIONS_FILE} | sed 's/[^0-9]*//g'`
# If we dont have any actions to take then we're done. Otherwise send an alert.
if [ ${ActionableItems} -eq 0 ]
then
echo "No actions needed"
#echo "No actions needed"|mailx -s "Notification:Disk monitor report generation suceed! [${VIPHOSTNAME}]" $email_list
else
echo "${ActionableItems} actionable items found!"
echo "Disk monitor report found actionable items! [${VIPHOSTNAME}]"
echo "Disk failure Found in [${VIPHOSTNAME}]" |mailx -s "Disk failure Found in [${VIPHOSTNAME}] " -a ${ACTIONS_FILE} $email_list
fi
# =============================================================================
# Script Completion
# =============================================================================
#Manish Jaiswal
#!/bin/sh
# =============================================================================
# Netezza Disk Monitor Template
# =============================================================================
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
email_list="NZRed@gmail.com,EDW_Support@gmail.com"
SCRIPTOUTPUTDIR=/export/home/nz/scripts/MONITOR
VIPHOSTNAME=EDW-NTZ-001-LQC
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}.DiskMonitor.${SCRIPTSTART}.txt"
export CLEAN_RPT_FILE="${SCRIPTOUTPUTDIR}/${VIPHOSTNAME}.DiskMonitor.${SCRIPTSTART}.clean.txt"
export ACTIONS_FILE="${SCRIPTOUTPUTDIR}/${VIPHOSTNAME}.DiskMonitor.${SCRIPTSTART}.actions.txt"
find $SCRIPTOUTPUTDIR/*txt -mtime +5 -exec rm {} \;
# -----------------------------------------------------------------------------
# Start the disk checks.
# -----------------------------------------------------------------------------
echo "Starting disk monitor for ${VIPHOSTNAME}"
#/nz/support-IBM_Netezza-7.2.0.7.P1-160122-1638/bin/adm/disk_monitor \
${NZSUPPORT7207BINDIR}/adm/disk_monitor > ${RPT_FILE} 2>&1
RetCode=$?
# Check the outcome.
if [ ${RetCode} -eq 0 ]
then
echo "Successful."
else
echo "FAILED!"
echo "Disk monitor report generation failure! [${VIPHOSTNAME}]" |mailx -s "Notification:Disk monitor report generation failure! [${VIPHOSTNAME}]" $email_list
fi
echo "Finished disk monitor for ${VIPHOSTNAME}"
# -----------------------------------------------------------------------------
# Check for actionable items and alert as needed.
# -----------------------------------------------------------------------------
echo "Checking ${VIPHOSTNAME} disk monitor report for actionable items"
# Strip the stderr output from the report.
sed -ne '/^[A-Z]/d;p' "${RPT_FILE}" | sed -e '/Fewer lines on second insert/d' > ${CLEAN_RPT_FILE}
# Extract the actionable portion of the report.
sed -n '/Actionable/,/^(/p' ${CLEAN_RPT_FILE} > ${ACTIONS_FILE}
# Get the number of actionable items.
ActionableItems=`grep "^(" ${ACTIONS_FILE} | sed 's/[^0-9]*//g'`
# If we dont have any actions to take then we're done. Otherwise send an alert.
if [ ${ActionableItems} -eq 0 ]
then
echo "No actions needed"
#echo "No actions needed"|mailx -s "Notification:Disk monitor report generation suceed! [${VIPHOSTNAME}]" $email_list
else
echo "${ActionableItems} actionable items found!"
echo "Disk monitor report found actionable items! [${VIPHOSTNAME}]"
echo "Disk failure Found in [${VIPHOSTNAME}]" |mailx -s "Disk failure Found in [${VIPHOSTNAME}] " -a ${ACTIONS_FILE} $email_list
fi
# =============================================================================
# Script Completion
# =============================================================================
No comments:
Post a Comment