Monday, April 16, 2012

script to check the preqreuiement of Oracle DB installation

# check sysctl
Check_Sysctl_Memstring()
{
FILE_MAX=""
FILE_MAX=`grep file-max /etc/sysctl.conf | grep ^fs.file-max | awk '{print $3}'`
if [ $FILE_MAX -eq 6815744 ];then
printf "%-80s %-20s\n\n" "fs.file-max is $FILE_MAX" "PASS" >> $OUT_FILE
else
printf "%-80s %-20s\n\n" "fs.file-max is $FILE_MAX, should be 6815744" "<>" >> $OUT_FILE
fi
}

# check swap
Check_Swap_Space()
{
SYS_SWAP=""
SYS_SWAP=`free -m | tail -1 | awk '{print $4}'`
if [ $SYS_SWAP -gt 16384 ]; then
printf "%-80s %-20s\n\n" "System swap is $SYS_SWAP, more than 16384MB" "PASS" >> $OUT_FILE
else
printf "%-80s %-20s\n\n" "System swap is $SYS_SWAP, less than 16384MB" "<>" >> $OUT_FILE
fi
}

# check EM agent

Check_EM_Agent()
{
# check if emagent is started
ps -ef | grep emagent >/dev/null 2>&1
if [ $? -eq 0 ]; then
printf "%-80s %-20s\n\n" "\"emagent\" is running" "PASS" >> $OUT_FILE
else
printf "%-80s %-20s\n\n" "\"emagent\" is not running" "<>" >> $OUT_FILE
fi
}


#
# port connectivity test
Check_Port_Connectivity()
{
if [ $# -eq 0 ]; then
echo "$ERROR_MISSINGARG"
echo " "
exit 1
fi


for myargs in "$@"
do
if [ $myargs = $ANALYTICS_HOST ]; then
echo " "
echo "checking port connectivity to $myargs on $PORT2 ..."
PORT_STATUS=`/usr/bin/nc -z -w 10 $myargs $PORT2 | awk '{print $7}'`
if [ "$PORT_STATUS" = "succeeded!" ]; then
printf "%-80s %-20s\n\n" "$myargs port $PORT2 accepting connections" "PASS" >> $OUT_FILE
else
printf "%-80s %-20s\n\n" "$myargs port $PORT2 connection failed" "<>" >> $OUT_FILE
fi
else
echo " "
echo "checking port connectivity to $myargs on $PORT1 ..."
PORT_STATUS=`/usr/bin/nc -z -w 20 $myargs $PORT1 | awk '{print $7}'`
if [ "$PORT_STATUS" = "succeeded!" ]; then
printf "%-80s %-20s\n\n" "$myargs port $PORT1 accepting connections" "PASS" >> $OUT_FILE
else
printf "%-80s %-20s\n\n" "$myargs port $PORT1 connection failed" "<>" >> $OUT_FILE
fi
fi
done
}


#
# check user ssh
# first time dsa keys are copied over, password prompt will be displayed
Check_User_SSH()
{
USER1=ororacrs
USER2=oraem
USER3=root
HOST1=fstlnx005

# run as oraem
su - $USER2 -c "ssh-copy-id -i ~/.ssh/id_dsa.pub $USER2@$HOST1" >/dev/null 2>&1
if [ $? -eq 0 ]; then
printf "%-80s %-20s\n\n" "Passwordless SSH for \"$USER2\"" "PASS" >> $OUT_FILE
else
printf "%-80s %-20s\n\n" "Passwordless SSH for \"$USER1\"" "<>" >> $OUT_FILE
fi


ssh-copy-id -i ~/.ssh/id_dsa.pub $USER3@$HOST1 >/dev/null 2>&1
if [ $? -eq 0 ]; then
printf "%-80s %-20s\n\n" "Passwordless SSH for \"$USER3\"" "PASS" >> $OUT_FILE
else
printf "%-80s %-20s\n\n" "Passwordless SSH for \"$USER3\"" "<>" >> $OUT_FILE
fi
}

# check SSH banner
Check_SSH_Banner()
{
SSH_BANNER=""
SSH_BANNER=`cat /etc/ssh/sshd_config | grep -i "#banner"`
if [ "`echo $SSH_BANNER | cut -c 1 | uniq`" = "#" ]; then
printf "%-80s %-20s\n\n" "SSH banner \"$SSH_BANNER\" commented out" "PASS" >> $OUT_FILE
else
printf "%-80s %-20s\n\n" "SSH banner NOT commented" "<>" >> $OUT_FILE
fi
}

No comments:

Post a Comment