Skip to content

Commit e17fdfe

Browse files
prod script
1 parent 501938a commit e17fdfe

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

scripts/check_file_delivery.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
3+
################################################################################
4+
# Name : check_file_delivery.sh #
5+
# Author : Ibrahim Musayev #
6+
# Purpose : To avoid single point of failure on condition #
7+
# when control-M is down or maintained. #
8+
# Time based job is running in CTM at 6 pm to alert in addition on #
9+
# not started ETL run. #
10+
# History : 05.10.21 Ibrahim Musayev, creation #
11+
################################################################################
12+
13+
TIMESTAMP=`date +'%Y%m%d_%H%M%S'`
14+
FILEPREFIX="CC"
15+
DATE=`date +'%y%m%d'`
16+
EXITCODE=0
17+
hostname=$(hostname -s)
18+
LOGFILE=$HOME/masterdata_monitor.log
19+
20+
21+
if [[ ${hostname:1:1} == "p" && ${hostname:7:3} == "a01" ]]; then
22+
FILEPREFIX="PBSI4C"
23+
FILENUMBER_MAX_MASTER=7
24+
FILENUMBER_MAX_CC=30
25+
elif [[ ${hostname:1:1} == "i" && ${hostname:7:3} == "a02" ]]; then
26+
FILENUMBER_MAX_MASTER=7
27+
FILENUMBER_MAX_CC=30
28+
elif [[ ${hostname:1:1} == "q" && ${hostname:7:3} == "a03" ]]; then
29+
FILEPREFIX="PBSI4C"
30+
FILENUMBER_MAX_MASTER=7
31+
FILENUMBER_MAX_CC=30
32+
else
33+
echo "${TIMESTAMP} WARN: Script called in a wrong environment or server ${hostname}. Exiting!" | tee -a ${LOGFILE}
34+
exit 0
35+
fi
36+
37+
if [[ ! -d $(dirname ${LOGFILE}) ]]; then
38+
mkdir -p $(dirname ${LOGFILE})
39+
fi
40+
41+
cd /opt/bsi/transfer/_master_current
42+
FILECOUNT=`find . -type f -print | grep "${FILEPREFIX}.MASTERDATA.*${DATE}.zip" |wc -l 2>/dev/null`
43+
44+
if [[ ${FILECOUNT} -lt ${FILENUMBER_MAX_MASTER} ]]; then
45+
echo "${TIMESTAMP} ERROR: Masterdata files are not processed. Setting status NOT OK" | tee -a ${LOGFILE}
46+
EXITCODE=1
47+
else
48+
echo "${TIMESTAMP} INFO: Masterdata files are successfully proceeded" | tee -a ${LOGFILE}
49+
fi
50+
51+
cd /opt/bsi/transfer/_cc_current
52+
FILECOUNT=`find . -type f -print | grep "${FILEPREFIX}.[M]*.*P${DATE}.*[0-9]" |wc -l 2>/dev/null`
53+
54+
if [[ ${FILECOUNT} -lt ${FILENUMBER_MAX_CC} ]]; then
55+
echo "${TIMESTAMP} ERROR: Masterdata files are not processed. Setting status NOT OK" | tee -a ${LOGFILE}
56+
EXITCODE=1
57+
else
58+
echo "${TIMESTAMP} INFO: Masterdata files are successfully proceeded" | tee -a ${LOGFILE}
59+
fi
60+
61+
exit ${EXITCODE}

0 commit comments

Comments
 (0)