<- Scripts
#!/bin/bash
# Purpose: Generates and sends DBSAT report.
# Version: 2018.10.01
# Dependencies: inc_system.sh
######################################
# Preamble: 2018.10.01 #
######################################
set -a; DIR_SCRIPTS="/u01/app/scripts"; source $DIR_SCRIPTS/inc_system.sh
sFullName=$(basename "$0"); me=${sFullName%.*}
sSLog="$DIR_LOGS/$me.sess.log"; sHLog="$DIR_LOGS/$me.hist.log"; > $sSLog
if [[ $MAINT_WINDOW -eq 1 ]]; then printf "Maintenance Window Detected - Exiting\n"; exit; fi
# User Vars
usrAppDir="/u01/app/dbsat"; # Dir DBSAT files installed to.
usrAppWrkDir="$usrAppDir/dnasolo"
#usrEmailList="michaele@sccu.com josed@sccu.com OS_DBASupport@fiserv.com Rune.Trondsen@Fiserv.com"
usrEmailList="michaele@sccu.com"
######################################
# Start #
######################################
clear; log "$sSLog" "$sFullName Started"; linesep
SysVars_show
printf "usrAppDir: $usrAppDir\n"
printf "usrAppWrkDir: $usrAppWrkDir\n"
linesep "="
sleep 3
# Validate Dir
if ! [[ -d $usrAppDir ]]; then
log "$sSLog" "$usrAppDir does not exist."
exit
fi
# Run the Collector
log "$sSLog" "Running the Collector"
cd $usrAppDir
CMD=$($usrAppDir/dbsat collect -n "/ as sysdba" $usrAppWrkDir > /dev/null 2>&1)
# Create Report Files
log "$sSLog" "Creating Report Files"
CMD=$($usrAppDir/dbsat report -n $usrAppWrkDir)
# Zip Report Files
log "$sSLog" "Zipping Files"
if [[ -f $usrAppDir/dbsat_$HOSTNAME.zip ]]; then
rm $usrAppDir/dbsat_$HOSTNAME.zip
fi
sZipFile="$usrAppDir/dbsat_$HOSTNAME.zip"
cd $usrAppDir
$ORACLE_HOME/bin/zip $sZipFile $usrAppDir/*.html
# Email
log "SLog" "Sending Email"
sMsg="Oracle Database Security Assessment Tool (DBSAT) report attached."
mail -s "DBSAT Report: $HOSTNAME" -a $sZipFile $usrEmailList <<< "$sMsg"
######################################
# End #
######################################
log "$sSLog" "$sFullName Ended [Elapse Time: $(elapse)]";
echo $(linesep "=") >> $sHLog; cat $sSLog >> $sHLog;
tail -32768 $sHLog > $sHLog.tmp; mv $sHLog.tmp $sHLog