!/bin/bash
#ORACLE MiddleWare Patch
Script to gather cpu and memory utilization statistics
!/bin/bash ##Written by Pankaj Kumar ##Define the process name PROCESS_NAME=”wdavdaemon” ##Define the output file OUTPUT_FILE=”wdavdaemon_stats.log” ##Function to gather CPU and memory statistics gather_stats() { echo “Timestamp: $(date)” >> $OUTPUT_FILE ps -C $PROCESS_NAME -o %cpu,%mem,cmd >> $OUTPUT_FILE echo “—————————————-” >> $OUTPUT_FILE } ##Initialize the output file echo “Gathering CPU and memory statistics for process: $PROCESS_NAME” > $OUTPUT_FILE echo “—————————————-” >> $OUTPUT_FILE ##Run the gather_stats function every hour for 24 hours or adjust the timing as per your requirements for ((i=0; i<4; i++)); do ##for ((i=0; i<24; i++)); do gather_stats sleep 4s done echo “Data collection complete.” |
Created by Pankaj Kumar
Version 1.0
April 25, 2024
updated 05112024
updated 13122024
updated 11042025
#
cdate=$(date +”%d%m%y%H%M”)
plog=patchlogs_$cdate.log
if [ “$1” -gt “-1” ]
then echo NO ARG
fi
if [ -z “$1” ]
then
echo “No patchname supplied for JDK like sh java-update.sh jdk-8u441-linux-x64.tar.gz”
exit 1
fi
if [ -e $1 ]
then
echo “Proceeding with the JAVA Update” >> $plog
echo “”
echo “”
echo “Ensure that JAVA_HOME is /u01/forms/products/jdk1.8.0_333”
echo “”
echo “”
sleep 10
echo “Middleware JAVA Patching —-” >> $plog
echo “Ensure backups are in place …. ” >> $plog
echo “Check JAVA Processes ” >> $plog
echo “” >> $plog
echo “” >> $plog
echo “Pass argument like sh java-update.sh jdkname.zip ” >> $plog
echo “” >> $plog
echo “” >> $plog
echo “” >> $plog
echo “————————————————————————————–” >> $plog
echo “” >> $plog
echo “” >> $plog
cdate=$(date +”%F”)
echo “”
echo “”
MW_HOME=/u01/forms/products/Middleware
JAVA_HOME=/u01/forms/products/jdk1.8.0_333
echo “##########JAVA Update specific Patching######” >> $plog
echo “######Date $cdate ########” >> $plog
dcheckforms=$(df -TH /u01/forms/products | awk ‘//{print $1, $5 }’ | awk ‘//{print $2 }’|awk ‘NR==2 {print $1}’ |sed s/’\G*$’//)
if [[ $dcheckforms -ge 15 ]]; then
echo “Enough Space on file system – forms”
df -TH /u01/forms/products
echo “Enough Space on file system – forms” >> $plog
echo “”
echo “”
echo “Proceeding with backups …”
echo “” >> $plog
echo “Proceeding with Middleware Backups ” >> $plog
echo “” >> $plog
cp -r $MW_HOME /u01/forms/products/Middleware.bkp.$cdate
cp -r $JAVA_HOME /u01/forms/products/jdk1.8.0_333.bkp.$cdate
echo "" >> $plog
else
echo “Please increase the disk space on forms”
df -TH /u01/forms/products
echo “Installation is aborted ….”
exit 1
fi
echo “” >> $plog
fi
echo “creating /tmp/fuser” >> $plog
touch /tmp/fuser
DOMAIN_HOME=/u01/forms/products/Middleware/user_projects/domains/formING_domain
export TWO_TASK=ORCL
export TNS_ADMIN=$DOMAIN_HOME/config/fmwconfig/
export TERM=vt220
export ORACLE_TERM=$TERM
. .profile
Reports server: Adjust as required to allow forms to get the reports server name
using “tool_env.getvar(‘REPORTS_SERVER_NAME’, v_rep_server);”
export REPORTS_SERVER_NAME=
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P15
export INSTANCE_HOME=$DOMAIN_HOME/config/fmwconfig/components/OHS/instances/ohs1
. ./.aliases
OPATCH_NO_FUSER=true
export PATH=/tmp:$PATH
patchdir=/var/tmp
echo “”
echo “”
cd /var/tmp
echo “Patch Validation check ” >> $plog
echo “” >> $plog
echo ” $1 ” >> $plog
sleep 5
if [ -f “$1” ]; then
echo “Proceeding with JAVA update $1 …. ” >> $plog
cd /var/tmp
echo "" >> $plog
echo $(pwd)
echo ""
cd /var/tmp
##$$echo "y" | unzip -q $1
tar -xzf $1
echo ""
echo ""
echo ""
echo ""
sleep 1
cp -r jdk1.8.0_441 /u01/forms/products/
##Infra JAVA update
cp /u01/forms/products/jdk1.8.0_333/jre/lib/security/cacerts /u01/forms/products/jdk1.8.0_441/jre/lib/security/
mv /u01/forms/products/jdk1.8.0_333 /u01/forms/products/jdk1.8.0_333.old.renamed.during.upgrade.$cdate
mv /u01/forms/products/jdk1.8.0_441 /u01/forms/products/jdk1.8.0_333
##Middleware Java Update
cp -r jdk1.8.0_441 /u01/forms/products/Middleware/oracle_common/
mv /u01/forms/products/Middleware/oracle_common/jdk /u01/forms/products/Middleware/oracle_common/jdk.old.$cdate
mv /u01/forms/products/Middleware/oracle_common/jdk1.8.0_441 /u01/forms/products/Middleware/oracle_common/jdk
echo "" >> $plog
echo "" >> $plog
echo ""
echo ""
fi
echo "#######################################" >> $plog
echo "Script finished at $cdate " >> $plog
echo "#######################################" >> $plog
echo ""
echo ""
else
echo "$1 is not present in $(pwd) directory, please check and try again" >> $plog
echo "$1 is not present in $(pwd) directory, please check and try again"
exit 1 >> $plog
fi