From 7a6f726e518795c7fa950cff6fffdb0898b6c084 Mon Sep 17 00:00:00 2001 From: Nivedithaa Mahendran Date: Fri, 29 Nov 2024 20:36:19 +0530 Subject: [PATCH] Updates --- .../120-ibm-db2u-database/files/DB2_Backup.sh | 6 ++- .../120-ibm-db2u-database/files/HADRMON.sh | 49 +++++++++++++++++++ .../120-ibm-db2u-database/files/Run_Backup.sh | 8 ++- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/instance-applications/120-ibm-db2u-database/files/DB2_Backup.sh b/instance-applications/120-ibm-db2u-database/files/DB2_Backup.sh index baa4b468..d8f21436 100755 --- a/instance-applications/120-ibm-db2u-database/files/DB2_Backup.sh +++ b/instance-applications/120-ibm-db2u-database/files/DB2_Backup.sh @@ -56,7 +56,9 @@ SLACK_NOTIFY() cat << ! >.curl_$database.sh curl -X POST -H 'Content-type: application/json' --data '{"text":"$slackdes"}' ${SLACKURL} ! +if [[ -n "${SLACKURL}" ]]; then /bin/bash .curl_$database.sh > .curl_$database.out 2>&1 +fi ##### Create ICD Incident #### ####### If Backup fails ### @@ -86,7 +88,9 @@ cat << ! >.curl_${database}_ICD.sh "hstype":"BACKUP" }' ! +if [[ -n "${ICD_AUTH_KEY}" ]]; then /bin/bash .curl_${database}_ICD.sh > .curl_${database}_ICD.out 2>&1 +fi } @@ -293,7 +297,7 @@ echo "BACKUP End time : ${DATETIME}" >> $BACK_LOG if [[ ${BKUP_STATUS} -gt 0 ]] then ### Send error alert - SLACK_NOTIFY + SLACK_NOTIFY fi ### Copy the current backup log to the Backup log history file diff --git a/instance-applications/120-ibm-db2u-database/files/HADRMON.sh b/instance-applications/120-ibm-db2u-database/files/HADRMON.sh index 23bd8cfb..1fc581a9 100755 --- a/instance-applications/120-ibm-db2u-database/files/HADRMON.sh +++ b/instance-applications/120-ibm-db2u-database/files/HADRMON.sh @@ -61,7 +61,9 @@ SLACK_NOTIFY() cat << ! >.curl_$database.sh curl -X POST -H 'Content-type: application/json' --data '{"text":"$longdes"}' $SLACKURL ! + if [[ -n "${SLACKURL}" ]]; then /bin/bash .curl_$database.sh > .curl_$database.out 2>&1 + fi } @@ -160,6 +162,7 @@ cat << ! >curl.sh }' ! SLACK_NOTIFY +if [[ -n "${ICD_AUTH_KEY}" ]]; then /bin/bash curl.sh > .curl_$database.out 2>&1 grep -v Received .curl.out | grep -v Dload | grep -v "\-\-:\-\-:\-\-" >$Maillog if [ -s $Maillog ]; then @@ -167,6 +170,11 @@ SLACK_NOTIFY echo $longdes >>$Maillog mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog fi +else + echo "###################################################" >>$Maillog + echo $longdes >>$Maillog + mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog +fi echo " ----------------- " >>$For_audit echo "HADR is not active at ${DATETIME}" >> $For_audit touch ${HOME}/.NOSEND_$instance @@ -219,6 +227,7 @@ cat << ! >curl.sh "hstype":"HADR" }' ! +if [[ -n "${ICD_AUTH_KEY}" ]]; then /bin/bash curl.sh > .curl.out 2>&1 grep -v Received .curl.out | grep -v Dload | grep -v "\-\-:\-\-:\-\-" >$Maillog if [ -s $Maillog ]; then @@ -226,6 +235,11 @@ cat << ! >curl.sh echo $longdes >>$Maillog mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog fi +else + echo "###################################################" >>$Maillog + echo $longdes >>$Maillog + mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog +fi touch ${HOME}/.NOSEND_$i if echo $i | grep -Ei "maxdb|tridb|bludb" >/dev/null then @@ -307,6 +321,7 @@ cat << ! >curl.sh "hstype":"HADR" }' ! +if [[ -n "${ICD_AUTH_KEY}" ]]; then /bin/bash curl.sh > .curl.out 2>&1 grep -v Received .curl.out | grep -v Dload | grep -v "\-\-:\-\-:\-\-" >$Maillog if [ -s $Maillog ]; then @@ -314,6 +329,11 @@ cat << ! >curl.sh echo $longdes >>$Maillog mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog fi +else + echo "###################################################" >>$Maillog + echo $longdes >>$Maillog + mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog +fi touch ${HOME}/.NOSEND_sdb_$i fi fi @@ -352,6 +372,7 @@ cat << ! >curl.sh "hstype":"HADR" }' ! +if [[ -n "${ICD_AUTH_KEY}" ]]; then /bin/bash curl.sh > .curl.out 2>&1 grep -v Received .curl.out | grep -v Dload | grep -v "\-\-:\-\-:\-\-" >$Maillog if [ -s $Maillog ]; then @@ -359,6 +380,11 @@ cat << ! >curl.sh echo $longdes >>$Maillog mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog fi +else + echo "###################################################" >>$Maillog + echo $longdes >>$Maillog + mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog +fi touch ${HOME}/.NOSEND_ddb_$i fi #continue @@ -400,6 +426,7 @@ cat << ! >curl.sh "hstype":"HADR" }' ! +if [[ -n "${ICD_AUTH_KEY}" ]]; then /bin/bash curl.sh > .curl.out 2>&1 grep -v Received .curl.out | grep -v Dload | grep -v "\-\-:\-\-:\-\-" >$Maillog if [ -s $Maillog ]; then @@ -407,6 +434,11 @@ cat << ! >curl.sh echo $longdes >>$Maillog mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog fi +else + echo "###################################################" >>$Maillog + echo $longdes >>$Maillog + mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog +fi touch ${HOME}/.NOSEND_sdb_$i fi fi @@ -446,6 +478,7 @@ cat << ! >curl.sh "hstype":"HADR" }' ! +if [[ -n "${ICD_AUTH_KEY}" ]]; then /bin/bash curl.sh > .curl.out 2>&1 grep -v Received .curl.out | grep -v Dload | grep -v "\-\-:\-\-:\-\-" >$Maillog if [ -s $Maillog ]; then @@ -453,6 +486,11 @@ cat << ! >curl.sh echo $longdes >>$Maillog mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog fi +else + echo "###################################################" >>$Maillog + echo $longdes >>$Maillog + mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog +fi touch ${HOME}/.NOSEND_ddb_$i fi fi @@ -509,6 +547,7 @@ cat << ! >curl.sh "hstype":"HADR" }' ! +if [[ -n "${ICD_AUTH_KEY}" ]]; then # /bin/bash curl.sh > .curl.out 2>&1 grep -v Received .curl.out | grep -v Dload | grep -v "\-\-:\-\-:\-\-" >$Maillog if [ -s $Maillog ]; then @@ -516,6 +555,10 @@ cat << ! >curl.sh echo $longdes >>$Maillog # mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog fi +else + echo "###################################################" >>$Maillog + echo $longdes >>$Maillog +fi touch ${HOME}/.NOSEND_$i fi #continue @@ -559,6 +602,7 @@ cat << ! >curl.sh "hstype":"HADR" }' ! +if [[ -n "${ICD_AUTH_KEY}" ]]; then /bin/bash curl.sh > .curl.out 2>&1 grep -v Received .curl.out | grep -v Dload | grep -v "\-\-:\-\-:\-\-" >$Maillog if [ -s $Maillog ]; then @@ -566,6 +610,11 @@ cat << ! >curl.sh echo $longdes >>$Maillog mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog fi +else + echo "###################################################" >>$Maillog + echo $longdes >>$Maillog + mail -s "$Server HADR error, but failed to create task through OSLC API" `cat $Mail_recp` < $Maillog +fi touch ${HOME}/.NOSEND_$i fi fi diff --git a/instance-applications/120-ibm-db2u-database/files/Run_Backup.sh b/instance-applications/120-ibm-db2u-database/files/Run_Backup.sh index 693534e0..72f29f0c 100755 --- a/instance-applications/120-ibm-db2u-database/files/Run_Backup.sh +++ b/instance-applications/120-ibm-db2u-database/files/Run_Backup.sh @@ -63,7 +63,9 @@ do longdes="Failure to start the Backup job ${DATETIME} CUST=${CUSTNAME} ${RC}" ## Send Failure notification to a slack channel ## cat << ! >.curl_${DBNAME}_RUN.sh - curl -X POST -H 'Content-type: application/json' --data '{"text":"$longdes"}' $SLACKURL + if [[ -n "${SLACKURL}" ]]; then + curl -X POST -H 'Content-type: application/json' --data '{"text":"$longdes"}' $SLACKURL + fi ! /bin/bash .curl_${DBNAME}_RUN.sh > .curl_${DBNAME}_RUN.out 2>&1 @@ -97,7 +99,9 @@ cat << ! >.curl_${DBNAME}_ICD.sh "hstype":"BACKUP" }' ! -/bin/bash .curl_${DBNAME}_ICD.sh > .curl_${DBNAME}_ICD.out 2>&1 +if [[ -n "${ICD_AUTH_KEY}" ]]; then + /bin/bash .curl_${DBNAME}_ICD.sh > .curl_${DBNAME}_ICD.out 2>&1 +fi fi done