top of page

Monitor Un_deployed War files Linux & Documentum Administration


################################################################ # # Program : v1: undeployed_war_files_monitor.sh # : Fredrick ADMIN # : Oct 2018 # : Server :vdcqle****** #################################################################

#!/bin/bash WILDFY="`ls /app/documentum| grep -E 'share|wildfly' | grep -v share`" SHARE="` ls /app/documentum| grep -E 'share|wildfly' | grep -v wildfly`" OUTWLDF="`ls /app/documentum| grep -E 'share|wildfly' | grep -v share |wc -m`" OUTSHARE="`ls /app/documentum| grep -E 'share|wildfly' | grep -v wildfly |wc -m`"

echo "**********************************************************************************************" echo "**********************************************************************************************"

echo "$OUTWLDF" && \ newfilename () {

MAILTO="MEEEEEE@GMAIL.com" HOSTNAME="`uname -n`" APPNAME=`ls -l /app/documentum/dba/| grep -i "dm_start_*" |grep -v .bak |awk '{print $9}' |cut -c10- | head -1` MESSGAE="War files were not deploed in Server `uname -n`"

FILE="new_filename" if [ -f "$FILE" ]; then echo "File $FILE: exists"; cp -r new_filename new_filename.txt; new_array=($(cat new_filename.txt)) for i in "${new_array[@]}"; do /bin/touch "$i"; done sleep 2; echo "Sending Email Notifications" MESSGAE="Some War files were not deploed after patching on Server `uname -n`" echo "$MESSGAE" >> new_filename.txt mail -s "$APPNAME: $HOSTNAME:Prod: Undeployments Alert " $MAILTO_ME < new_filename.txt sleep 5; echo "Cleanup Time**********************" mv new_filename missed_depld.bak rm -f new_filename.txt echo "Good &Done!" exit 0

else echo "Empty String: No undeployed files : Quiting ***************************"; exit 1; fi }

deployscript() { cd "$DEPLOY" && \ undeployeddata=( $( ls | grep -i "undeployed"|cut -d "." -f1-2)) sleep 2; echo "${undeployeddata[@]}"; echo "Backup_udeployed files" ls |grep undeployed > failed-deploy.bak echo "creating new files for deployments" len="${#undeployeddata[*]}";

for ((i=0; i<${len}; i++)); do echo "${undeployeddata[$i]}".dodeploy >> new_filename; done sleep 5; echo "calling filename _last-section of the script" newfilename; sleep 5; echo "Good & Done!" }

deployersscript() {

cd "$DEPLOYERS" && \ echo "Handling deployers section" undeployeddata=( $( ls | grep -i "undeployed"|cut -d "." -f1-2)) sleep 2; echo "${undeployeddata[@]}"; echo "Backup_udeployed files" ls |grep undeployed > failed-deploy.bak echo "creating new files for deployments" len="${#undeployeddata[*]}"; for ((i=0; i<${len}; i++)); do echo "${undeployeddata[$i]}".dodeploy >> new_filename; done sleep 5; echo "calling filename _last-section of the script" newfilename; sleep 5; echo "Good & Done!"

}

deploymentscript() { cd "$DEPLOYMENTS" && \ echo "Handling deployments section" undeployeddata=( $( ls | grep -i "undeployed"|cut -d "." -f1-2)) sleep 2; echo "${undeployeddata[@]}"; echo "Backup_udeployed files" ls |grep undeployed > failed-deploy.bak echo "creating new files for deployments" len="${#undeployeddata[*]}"; for ((i=0; i<${len}; i++)); do echo "${undeployeddata[$i]}".dodeploy >> new_filename; done sleep 5; echo "calling filename _last-section of the script" newfilename; sleep 5; echo "Good & Done!"

}

exactz_file() {

if [[ $(ls | grep -i "deployers"'$' |wc -l) -ge 1 ]] && [[ $(ls | grep -i "deploy"'$' |wc -l) -ge 1 ]]; then echo "Both files Present"; DEPLOY=$(ls | grep -i "deploy"'$') DEPLOYERS=$(ls | grep -i "deployers"'$')

echo "Handling Deploy First *********" deployscript; sleep 5; echo "Good & Done!" echo "************************************************************************************" echo "Hnadling deployers piece *********" deployersscript; sleep 5; echo "Good & Done!" echo "************************************************************************************"

elif [[ $(ls | grep -i "deployers"'$' |wc -l) -ge 1 ]] && [[ $(ls | grep -i "deploy"'$' |wc -l) -ge 0 ]]; then echo "Only deployers is Found: Mostly not feasible"; DEPLOYERS=$(ls | grep -i "deployers"'$') echo "Only one sectio present : handling Deployers" deployersscript; sleep 5; echo "Good & Done!" echo "************************************************************************************"

elif [[ $(ls | grep -i "deployers"'$' |wc -l) -ge 0 ]] && [[ $(ls | grep -i "deploy"'$' |wc -l) -ge 1 ]]; then echo "Only deploy is Found"; DEPLOY=$(ls | grep -i "deploy"'$') echo "Only deploy present: handling deploy ***" deployscript; sleep 5; echo "Good & Done!" echo "************************************************************************************"

elif [[ $(ls | grep -i "deployments"'$' |wc -l) -ge 1 ]] && [[ $(ls | grep -i "deploy"'$' |wc -l) -ge 0 ]] && [[ $(ls | grep -i "deployers"'$' |wc -l) -ge 0 ]]; then echo "Only deployments is Found"; DEPLOYMENTS=$(ls | grep -i "deployments"'$') echo "Only drployments exist : handling deployments ***" deploymentscript; sleep 5; echo "Good & Done!" echo "************************************************************************************" else echo "Error: Unable to locate deployment files"; fi

}

methodexist() {

echo "***********************************************************************" if [[ $(ls $DCTM_METHOD_SERVER |wc -l) -ge 1 ]] >/dev/null 2>&1; then echo "Dir present: Proceeding ***"; cd "$DCTM_METHOD_SERVER" && \ exactz_file; sleep 1; echo "Good & Done" else echo "Dir Missing...skipping"; fi }

webcacheexist() {

echo "***********************************************************************"

if [[ $(ls $DCTM_WEBCACHE_SERVER |wc -l) -ge 1 ]] >/dev/null 2>&1; then echo "Dir present : Proceeding ***"; cd "$DCTM_WEBCACHE_SERVER" && \ exactz_file; sleep 1; echo "Good & Done" else echo "Dir Missing...skipping"; fi }

startmethod() {

if [[ $OUTWLDF -gt 2 ]] && [[ $OUTSHARE -gt 2 ]]; then echo "Both file exist"; EXPLORE_WILDFY="$WILDFY" JBOSS_DIR="/app/documentum/$EXPLORE_WILDFY" DCTM_METHOD_SERVER="$JBOSS_DIR/server/DctmServer_MethodServer" DCTM_WEBCACHE_SERVER="$JBOSS_DIR/server/DctmServer_WEBCACHE" echo "***********************************************************************" echo "Validating method string******" methodexist; echo "***********************************************************************" echo "Validating webcache string******" webcacheexist; echo "Good &Done!" echo "***********************************************************************"

elif [[ $OUTWLDF -le 0 ]] && [[ $OUTSHARE -gt 2 ]]; then echo "Only $OUTSHARE file exist"; EXPLORE_SHARE="$OUTSHARE" JBOSSQUERY="`ls /app/documentum/$EXPLORE_SHARE/ | grep -E 'jboss|wildfly' | grep -v old | sort -rg |awk 'FNR==1{print $1}'`" JBOSS_DIR="/app/documentum/$EXPLORE_SHARE/$JBOSSQUERY" DCTM_METHOD_SERVER="$JBOSS_DIR/server/DctmServer_MethodServer" DCTM_WEBCACHE_SERVER="$JBOSS_DIR/server/DctmServer_WEBCACHE" echo "***********************************************************************" echo "Validating method string******" methodexist; echo "***********************************************************************" echo "Validating webcache string******" webcacheexist; echo "Good &Done!" echo "***********************************************************************"

elif [[ $OUTWLDF -gt 2 ]] && [[ $OUTSHARE -le 0 ]]; then echo "Only $OUTWLDF file exist"; EXPLORE_SHARE="$OUTWLDF" JBOSS_DIR="/app/documentum/$EXPLORE_SHARE/" DCTM_METHOD_SERVER="$JBOSS_DIR/server/DctmServer_MethodServer" DCTM_WEBCACHE_SERVER="$JBOSS_DIR/server/DctmServer_WEBCACHE" echo "***********************************************************************" echo "Validating method string******" methodexist; echo "***********************************************************************" echo "Validating webcache string******" webcacheexist; echo "Good &Done!" echo "***********************************************************************"

elif [[ $OUTWLDF -le 0 ]] && [[ $OUTSHARE -le 0 ]]; then echo " Both fiile Missing"; echo " wildfly & share Missing : this is not a content server" else echo "Unknown files! Proceed manually"

fi }

######################## #main script startmethod

bottom of page