######################################################################
# Checking status of the PeopleSoft Domains and send an alert #
# email if the domain is down and will check the domain #
# status again if domains are up and running fine. #
# #
# #
# Created by - Sudhir N Ravindra #
# Created Date - 28th JUNE 2022 #
# #
######################################################################
#!/bin/bash
domain=$1
flag=$2
envdom=`echo "${domain,,}"`
appdom=`echo "${domain^^}"`
. /home/psoft/.profile.$envdom > /dev/null 2>&1
touch /opt/psoft/pscusthome/admin_scripts/Domain_check.log
LOGFILE=/opt/psoft/pscusthome/admin_scripts/Domain_check.log
SUBJECT="Environment status ALERT!!! | $flag $appdom domain is down"
TO="sudhir.ravindra@gmail.com"
if [[ $flag == "APP" ]]; then
APPSERV_CHECK=`ps -ef | grep BBL | grep $PS_CFG_HOME/appserv/$appdom/LOGS/TUXLOG | grep -c " "`
if [ $APPSERV_CHECK -eq 1 ]
then
echo "----------------------------------------------------------------------------------" >> $LOGFILE
echo "Application server domain $appdom is running."
echo "----------------------------------------------------------------------------------" >> $LOGFILE
rm $LOGFILE
else
echo "Application server domain $appdom is not running." >>$LOGFILE
echo "----------------------------------------------------------------------------------" >> $LOGFILE
mail -r Peoplesoft.Admin@gmail.com -s "$SUBJECT" "$TO" < $LOGFILE
sleep 10m
if [[ $APPSERV_CHECK -le 0 ]]; then
mail -r Peoplesoft.Admin@gmail.com -s "$SUBJECT 2nd reminder email" "$TO" < $LOGFILE
rm $LOGFILE
fi
fi
fi
if [[ $flag == "PRCS" ]]; then
SCHEDULER_CHECK=`ps -ef | grep BBL | grep $PS_CFG_HOME/appserv/prcs/$appdom/LOGS/TUXLOG | grep -c " "`
if [ $SCHEDULER_CHECK -eq 1 ]
then
echo "----------------------------------------------------------------------------------" >> $LOGFILE
echo "Process Scheduler domain $appdom is running."
echo "----------------------------------------------------------------------------------" >> $LOGFILE
rm $LOGFILE
else
echo "Process Scheduler domain $appdom is not running." >>$LOGFILE
echo "----------------------------------------------------------------------------------" >> $LOGFILE
mail -r Peoplesoft.Admin@gmail.com -s "$SUBJECT" "$TO" < $LOGFILE
sleep 10m
if [[ $SCHEDULER_CHECK -le 0 ]]; then
mail -r Peoplesoft.Admin@gmail.com -s "$SUBJECT 2nd reminder email" "$TO" < $LOGFILE
rm $LOGFILE
fi
fi
fi
if [[ $flag == "WEB" ]]; then
WEBSERV_CHECK=`ps -ef | grep java | grep $envdom | grep -c " "`
if [ $WEBSERV_CHECK -eq 1 ]
then
echo "----------------------------------------------------------------------------------" >> $LOGFILE
echo "WEB Server doamin $appdom is running."
echo "----------------------------------------------------------------------------------" >> $LOGFILE
rm $LOGFILE
else
echo "WEB Server domain $appdom is not running." >>$LOGFILE
echo "----------------------------------------------------------------------------------" >> $LOGFILE
mail -r Peoplesoft.Admin@gmail.com -s "$SUBJECT" "$TO" < $LOGFILE
sleep 10m
if [[ $WEBSERV_CHECK -le 0 ]]; then
mail -r Peoplesoft.Admin@gmail.com -s "$SUBJECT 2nd reminder email" "$TO" < $LOGFILE
rm $LOGFILE
fi
fi
fi
=========================================================================
startApp.sh
usage - ./startApp.sh <ENV> ALL
#!/bin/ksh
domain=$1
typeset -u appdomain
appdomain=$1
flag=$2
. /home/psoft/.profile.$domain
if [[ $flag == "APP" ]]; then
psadmin -c parallelboot -d $appdomain
elif [[ $flag == "PRCS" ]]; then
psadmin -p start -d $appdomain
elif [[ $flag == "WEB" ]]; then
psadmin -w start -d $domain
elif [[ $flag == "ALL" ]]; then
psadmin -c start -d $appdomain
psadmin -p start -d $appdomain
psadmin -w start -d $domain
fi
=========================================================================
stopApp.sh
usage - ./stopApp.sh <ENV> ALL
#!/bin/ksh
domain=$1
typeset -u appdomain
appdomain=$1
flag=$2
. /home/psoft/.profile.$domain
if [[ $flag == "APP" ]]; then
psadmin -c stop -d $appdomain
elif [[ $flag == "PRCS" ]]; then
psadmin -p stop -d $appdomain
elif [[ $flag == "WEB" ]]; then
psadmin -w shutdown -d $domain
elif [[ $flag == "ALL" ]]; then
psadmin -w shutdown -d $domain
psadmin -c stop -d $appdomain
psadmin -p stop -d $appdomain
fi
=========================================================================
######################################################################
# #
# Created by - Sudhir N Ravindra #
# #
# Created Date - 29th March 2020 #
# #
######################################################################
#!/bin/bash
hostname=`hostname`
service=BBL
#email=`cat /opt/psoft/pscusthome/admin_scripts/email.lst`
subject="NAS MOUNT ALERT!!! on"
email=Sudhir.Ravindra@gmail.com
host=`cat /home/psoft/host.lst`
for i in $host
do
u="$i"
uu=`echo "${u^^}"`
l="$i"
ll=`echo "${l,,}"`
. /home/psoft/.profile.$ll
home=$PS_HOME
app=$PS_APP_HOME
cust=$PS_CUST_HOME
if [ -d "$home" ]; then
echo PS_HOME is Avalilable !!!
else
echo "The NAS Mount Point "$home" on `hostname` is missing, take necessary action!!!" | mailx -s "$subject `hostname`" $email
#$PS_HOME/setup/psrun.mak PS_HOME
#$PS_HOME/setup/psrun.mak PS_APP_HOME
#$PS_HOME/setup/psrun.mak PS_CUST_HOME
=========================================================================
######################################################################
# Rename the file in NAS path with date #
# #
# #
# Created by - Sudhir N Ravindra #
# Created Date - 16th MAY 2022 #
# #
######################################################################
#!/bin/bash
SUBJECT="File rename: SimplifyVMSContractorWeekly in QA server | $(date)"
LOGFILE="/opt/psoft/pscusthome/admin_scripts/log.log"
TO="sudhir.ravindra@gmail.com"
dt=`date +"%d%b%y"`
SCRIPTDIR=<Path_for_file>
FILE=<FILE_NAME>
cd $SCRIPTDIR
echo "----------------------------------------------------------------------------------" >> $LOGFILE
if [ -f "$FILE" ]; then
echo "$FILE is available."
echo File: $FILE file is available, renaming the file. >> $LOGFILE
mv $FILE FILE_NAMEy_$dt >>$LOGFILE
else
echo "$FILE does not exist." >>$LOGFILE
fi
echo "----------------------------------------------------------------------------------" >> $LOGFILE
if [ -f "FILE_NAMEy_$dt" ]; then
echo "$FILE exists."
echo File renamed to: `ls FILE_NAME_$dt` >> $LOGFILE
echo "----------------------------------------------------------------------------------" >> $LOGFILE
else
echo "File not found in the path..." >>$LOGFILE
echo "----------------------------------------------------------------------------------" >> $LOGFILE
fi
mail -r Peoplesoft.Admin@gmail.com -s "$SUBJECT" "$TO" < $LOGFILE
rm $LOGFILE
exit
=========================================================================
######################################################################
# This script will monitor Disk Space of below filesystem #
# And sends email alert if usage of filesystem is #
# more than 88% #
# #
# /opt/psoft/pscfghome #
# /opt/psoft/pstools #
# /opt/psoft/psapphome #
# /opt/psoft/pscusthome #
# #
# Created by - Sudhir N Ravindra #
# #
# Created Date - 18th March 2021 #
# #
######################################################################
#!/bin/bash
email=`cat /opt/psoft/pscusthome/admin_scripts/email.lst`
subject="Disk Space ALERT!!! on"
PSPWD=$(<~/.hcmpinfo)
alert=86
#for server in `cat /opt/psoft/pscusthome/admin_scripts/host.lst`
for server in `cat /opt/psoft/pscusthome/admin_scripts/hcmp_host.lst`
do
cfg=$(sshpass -p $PSPWD ssh psoft@$server df /opt/psoft/pscfghome | awk {'print $5'}|sed -ne 2p |cut -d"%" -f1)
if [ $cfg -gt $alert ]; then
echo "The Mount Point "/opt/psoft/pscfghome" on $server server used $cfg percent, take necessary action before Incident is triggered!!!" | mailx -s "$subject $server : $cfg% used" $email
else
echo "The mount is fine!!!"
fi
tools=$(sshpass -p $PSPWD ssh psoft@$server df /opt/psoft/pstools | awk {'print $5'}|sed -ne 2p |cut -d"%" -f1)
if [ $tools -gt $alert ]; then
echo "The Mount Point "/opt/psoft/pstools" on $server server used $tools percent, take necessary action before Incident is triggered!!!" | mailx -s "$subject $server : $tools% used" $email
else
echo "The mount is fine!!!"
fi
app=$(sshpass -p $PSPWD ssh psoft@$server df /opt/psoft/psapphome | awk {'print $5'}|sed -ne 2p |cut -d"%" -f1)
if [ $app -gt $alert ]; then
echo "The Mount Point "/opt/psoft/psapphome" on $server server used $app percent, take necessary action before Incident is triggered!!!" | mailx -s "$subject $server : $app% used" $email
else
echo "The mount is fine!!!"
fi
cust=$(sshpass -p $PSPWD ssh psoft@$server df /opt/psoft/pscusthome | awk {'print $5'}|sed -ne 2p |cut -d"%" -f1)
if [ $cust -gt $alert ]; then
echo "The Mount Point "/opt/psoft/pscusthome" on $server server used $cust percent, take necessary action before Incident is triggered!!!" | mailx -s "$subject $server : $cust% used" $email
else
echo "The mount is fine!!!"
fi
done
create a file email.lst and add email DL in it.
=========================================================================
######################################################################
# This script will check memory in all the PeopleSoft servers. #
# and send email if it reaches treshold to the team. #
# #
# Created by - Sudhir N Ravindra #
# Created Date - 22nd July 2021 #
# #
######################################################################
#!/bin/bash
hcminfo=$(<~/.envdev)
for server in `cat /home/psoft/mon/server-list.txt`
do
memusage=$(sshpass -p $hcminfo ssh psoft@$server free -t | awk 'FNR == 2 {printf("%d"), $3/$2*100}')
if [ $memusage -lt 80 ]; then
echo " Server memory is fine in $server "
else
SUBJECT="ATTENTION: Memory Utilization is High on $server at $(date)"
MESSAGE="/home/psoft/mon/Mail1.out"
TO="Sudhir.Ravindra@gmail.com"
echo "Memory Current Usage is: $memusage% in $server" >> $MESSAGE
echo "" >> $MESSAGE
echo "------------------------------------------------------------------" >> $MESSAGE
echo "Top Memory Consuming Processes Using top command" >> $MESSAGE
echo "------------------------------------------------------------------" >> $MESSAGE
echo "$(top -b -o +%MEM | head -n 20)" >> $MESSAGE
echo "" >> $MESSAGE
echo "------------------------------------------------------------------" >> $MESSAGE
echo "Total Memory consumed by each user" >> $MESSAGE
echo "------------------------------------------------------------------" >> $MESSAGE
echo "$(ps axo user,pcpu,pmem,rss --no-heading | awk '{pCPU[$1]+=$2; pMEM[$1]+=$3; sRSS[$1]+=$4} END {for (user in pCPU) if (pCPU[user]>0 || sRSS[user]>10240) printf "%s:@%.1f%% of total CPU,@%.1f%% of total MEM@(%.2f GiB used)\n", user, pCPU[user], pMEM[user], sRSS[user]/1024/1024}' | column -ts@ | sort -rnk2)" >> $MESSAGE
echo
echo "------------------------------------------------------------------" >> $MESSAGE
echo "Memory usage" >> $MESSAGE
echo "------------------------------------------------------------------" >> $MESSAGE
echo "$(free -h)" >> $MESSAGE
echo "" >> $MESSAGE
echo
echo
echo "------------------------------------------------------------------" >> $MESSAGE
echo "Virtual memory statistics report" >> $MESSAGE
echo "------------------------------------------------------------------" >> $MESSAGE
echo "$(vmstat 2 5 -t -w)" >> $MESSAGE
echo "" >> $MESSAGE
mail -r Peoplesoft.Admin@gmail.com -s "$SUBJECT" "$TO" < $MESSAGE
rm /home/psoft/mon/Mail1.out
fi
done
exit
=========================================================================
server_monitorin.sh
######################################################################
# #
# Created by - Sudhir N Ravindra #
# #
# Created Date - 14th December 2020 #
# #
######################################################################
#!/bin/bash
hcminfo=$(<~/.envdev)
echo "Server_Name CPU Memory Swap" >> /home/psoft/mon/cpu-mem-swap.txt
for server in `cat /home/psoft/mon/server-list.txt`
do
scpu=$(sshpass -p $hcminfo ssh $server cat /proc/stat | awk '/cpu/{printf("%.2f%\n"), ($2+$4)*100/($2+$4+$5)}' | awk '{print $0}' | head -1)
smem=$(sshpass -p $hcminfo ssh $server free | awk '/Mem/{printf("%.2f%"), $3/$2*100}')
sswap=$(sshpass -p $hcminfo ssh $server free | awk '/Swap/{printf("%.2f%"), $3/$2*100}')
echo "$server $scpu $smem $sswap" >> /home/psoft/mon/cpu-mem-swap.txt
done
#######################################
# email section
#######################################
OUT_FILE="/home/psoft/mon/tmpfile.html"
EMAIL_TO="sudhirsunil@gmail.com"
LOG_FILE="/home/psoft/mon/cpu-mem-swap.txt"
SUBJECT="DEV Env - CPU and Memory Report as of `date +"%m %B %Y"`"
awk 'BEGIN{print "<html><body bgcolor=#ededca text=#0f0f0e><table border=2>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table></body></html>"}' "$LOG_FILE" >> "$OUT_FILE"
(
echo "To: $EMAIL_TO"
echo "Subject: $SUBJECT"
echo "Content-Type: text/html"
echo
cat "$OUT_FILE"
) | /usr/sbin/sendmail -t
rm ${LOG_FILE} >/dev/null 2>&1
rm ${OUT_FILE} >/dev/null 2>&1
exit
=========================================================================
######################################################################
# This script will copy files and folders to multiple servers. #
# and send email if it reaches treshold to the team. #
# #
# Created by - Sudhir N Ravindra #
# Created Date - 22nd July 2021 #
# #
######################################################################
#
#!/bin/bash
dt=`date +"%d%b%y"`
OUTPUT_FILE=/opt/psoft/CDs/copy/copy_$dt.log
touch $OUTPUT_FILE
dev=$(<~/.envdev)
for server in `more dev_server_list.txt`
do
hostname
sshpass -p $dev scp -rp $1 psoft@$server:$2 2> $OUTPUT_FILE
email=`cat /opt/psoft/CDs/copy/email.lst`
SUBJECT="Status of the copy in $server server."
echo "The following File/Directory has been copied from
server `hostname` --> $1
to
server $server --> $2" > $OUTPUT_FILE
mail -s "$SUBJECT" $email < $OUTPUT_FILE
rm $OUTPUT_FILE
done
oracle user:
######################################################################
# This script will copy files and folders to multiple servers. #
# and send email if it reaches treshold to the team. #
# #
# Created by - Sudhir N Ravindra #
# Created Date - 22nd July 2021 #
# #
######################################################################
#
#!/bin/bash
dt=`date +"%d%b%y"`
OUTPUT_FILE=/opt/psoft/CDs/copy_ora/copy_$dt.log
touch $OUTPUT_FILE
dev=$(<~/.envora)
for server in `more /opt/psoft/CDs/copy_ora/dev_server_list.txt`
do
hostname
sshpass -p $dev scp -rp $1 oracle@$server:$2 2> $OUTPUT_FILE
email=`cat /opt/psoft/CDs/copy_ora/email.lst`
SUBJECT="Status of the copy in $server server."
echo "The following File/Directory has been copied from
server `hostname` --> $1
to
server $server --> $2" > $OUTPUT_FILE
mail -s "$SUBJECT" $email < $OUTPUT_FILE
rm $OUTPUT_FILE
done
=========================================================================
######################################################################
# This script will stop all the PeopleSoft applications. #
# Add PeopleSoft domain names in /home/psprod/ps_boot/env.lst file #
# #
# Created by - Sudhir N Ravindra #
# Created Date - 12th July 2020 #
# #
######################################################################
#!/bin/bash
hostname=`hostname`
service=BBL
email=sudhirsunil@gmail.com
############# Starts the PeopleSoft Apps #############
host=`cat /home/psprod/ps_boot/env.lst`
for i in $host
do
u="$i"
uu=`echo "${u^^}"`
l="$i"
ll=`echo "${l,,}"`
apps=`ps -ef | grep -v grep | grep $service | grep $uu | wc -l`
if [ $apps -le 0 ]; then
. /home/psprod/.profile.$ll
cd $PS_HOME/appserv
psadmin -c start -d $uu
apps=`ps -ef | grep -v grep | grep $service | grep $uu | wc -l`
if [ $apps -gt 0 ]; then
rm /home/psprod/ps_boot/ps_start.log
log=/home/psprod/ps_boot/ps_start.log
echo ========================== APP DOMAIN $uu ========================== >>$log
psadmin -c sstatus -d $uu >>$log
echo >>$log
echo >>$log
subject="PeopleSoft services at $uu has been started in $hostname"
echo "PeopleSoft services at $uu has been started in $hostname." | mailx -s "$subject" -a $log $email
############# If apps are not started in above section then will sleep for 10 min and starts the apps again #############
elif [[ $apps -le 0 ]]; then
sleep 10m
psadmin -c start -d $uu
apps=`ps -ef | grep -v grep | grep $service | grep $uu | wc -l`
if [ $apps -gt 0 ]; then
subject="PeopleSoft services at $uu has been started in $hostname"
echo "PeopleSoft services at $uu wasn't running and has been started in $hostname." | mailx -s "$subject" $email
############# If apps are not started in above section even after sleep fo 20 min and then send emmail saying apps not started #############
else
apps=`ps -ef | grep -v grep | grep $service | grep $uu | wc -l`
if [ $apps -le 0 ]; then
subject="PeopleSoft services of $uu is not running in $hostname"
echo "PeopleSoft services at $uu is stopped and cannot be started in $hostname. Please check...
NOTE: Check if Database is accessable" | mailx -s "$subject" $email
fi
fi
fi
fi
done
=========================================================================
######################################################################
# This script will stop all the PeopleSoft applications. #
# Add PeopleSoft domain names in /home/psprod/ps_boot/env.lst file #
# #
# Created by - Sudhir N Ravindra #
# Created Date - 12th July 2020 #
# #
######################################################################
#!/bin/bash
hostname=`hostname`
email=sudhirsunil@gmail.com
exec > /home/psprod/ps_boot/ps_stop_all.log
############################################
host=`cat /home/psprod/ps_boot/env.lst`
for i in $host
do
u="$i"
uu=`echo "${u^^}"`
l="$i"
ll=`echo "${l,,}"`
. /home/psprod/.profile.$ll
cd $PS_HOME/appserv
psadmin -c stop -d $uu
psadmin -c cleanipc -d $uu
#psadmin -c stop -d $ibhost
#psadmin -c cleanipc -d $ibhost
rm -f /home/psprod/ps_boot/ps_stop.log
log=/home/psprod/ps_boot/ps_stop.log
echo ========================== APP DOMAIN $uu ========================== >>$log
psadmin -c sstatus -d $uu >>$log
echo >>$log
echo >>$log
subject="PeopleSoft services at $uu is stopped in $hostname"
#echo "PeopleSoft services at $uu is stopped in $hostname." | mailx -s "$subject" -a $log $email
echo "PeopleSoft services at $uu is stopped in $hostname." | mailx -s "$subject" -a $log $email
done
=========================================================================
######################################################################
# This script will check take backup of Table PS_JOB #
# and sends table count of original and backup table over email #
# for Service Request 1810445 #
# #
# Created by - Sudhir N Ravindra #
# Created Date - 06nd August 2021 #
# #
######################################################################
#!/bin/ksh
. /home/psprod/.profile.env > /dev/null 2>&1
pwd=$(<~/.hcminfo)
dt=`date +"%d%b%y"`
SUBJECT="Backup of Table PS_JOB $(date)"
MESSAGE="/opt/psoft/pscusthome/sudhir/PS_JOB.log"
TO="sudhirsunil@gmail.com"
sqlplus PSHCM/$pwd@<DB_NAME> << EOF
set heading off
begin
execute immediate 'create table PS_JOB_BKP_'||to_char(sysdate,'DDMONYY')||' as select * from PS_JOB';
end;
/
commit;
SPOOL /opt/psoft/pscusthome/sudhir/PS_JOB.log;
select dbname from psdbowner;
Select count(*) from PS_JOB;
Select count(*) from PS_JOB_BKP_$dt;
grant select on pshcm.PS_JOB_BKP_$dt to psselect;
SPOOL OFF
EXIT;
EOF
mail -s "$SUBJECT" "$TO" < $MESSAGE
rm /opt/psoft/pscusthome/sudhir/PS_JOB.log
=========================================================================
SYNONYM:
set echo off pages 0 trimsp on lines 999 feed off;
spool createsyns.sql;
select 'create public synonym '||object_name||' for pshcm.'|| object_name||';' from dba_objects
where owner = 'PSHCM'
and object_type in ('TABLE', 'VIEW')
and substr(object_name,1,2) = 'PS'
minus
select 'create public synonym '||object_name||' for pshcm.'|| object_name||';'
from dba_objects
where object_type = 'SYNONYM'
and substr(object_name,1,2) = 'PS' ;
spool off;
set echo on feed on;
spool createsyns.log;
@createsyns;
spool off;
set echo off pages 0 trimsp on lines 999 feed off;
spool grantcnv.sql;
select 'grant insert, update, delete on pshcm.'||object_name||' to psconvert;' from dba_objects
where owner = 'PSHCM'
and object_type in ('TABLE', 'VIEW')
and substr(object_name,1,2) = 'PS'
minus
select unique 'grant insert, update, delete on pshcm.'||table_name||' to psconvert;'
from dba_tab_privs
where grantee = 'PSCONVERT';
spool off;
set echo on feed on;
spool grantcnv.log;
@grantcnv;
spool off;
set echo off pages 0 trimsp on lines 999 feed off;
spool grantsel.sql;
select 'grant select on pshcm.'||object_name||' to psselect;'
from dba_objects
where owner = 'PSHCM'
and object_type in ('TABLE', 'VIEW')
and substr(object_name,1,2) = 'PS'
minus
select unique 'grant select on pshcm.'||table_name||' to psselect;'
from dba_tab_privs
where grantee = 'PSSELECT';
spool off;
set echo on feed on;
spool grantsel.log;
@grantsel;
spool off;
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================
=========================================================================