Hi,
I have a job schedular file(job runs on that particular time):
cat set_schd.cfg
#JOB SCHEDULES
BLLBD101 05:30
BLLBD102 06:40
BLLBD103 06:45
DWLBD104 07:15
BLLBD105 08:10
DWLBD106 08:30
DWLBD107 08:35
DWLBD108 09:15
DWLBD109 09:30
DWLBD110 09:35
BLLBD201 13:15
DWLBD202 13:25
DWLBD203 13:30
DWLBD204 14:20
DWLBD205 14:40
DWLBD206 14:45
BLLBD301 17:45
DWLBD302 18:00
DWLBD303 18:05
DWLBD304 18:40
DWLBD305 19:00
DWLBD306 18:30
DWLBD307 19:05
BLLBD401 22:15
DWLBD402 23:00
DWLBD403 23:15
DWLBD404 23:55
DWLBD405 05:30
DWLBD406 06:00
as per above schedule we will receive messages of jobs with good run or bad run
sometime job will start late and accordingly will get messages, considering this i have prepared a code, can some one please verify if the code satisfies all the conditions? could someone please advise if needs any modifications to the script?
Code:
#JOB LIST
#---------------------------------------------------------------#
JBLIST_FULL[0]="BLLBD101"
JBLIST_FULL[1]="BLLBD102"
JBLIST_FULL[2]="BLLBD103"
JBLIST_FULL[3]="DWLBD104"
JBLIST_FULL[4]="BLLBD105"
JBLIST_FULL[5]="DWLBD106"
JBLIST_FULL[6]="DWLBD107"
JBLIST_FULL[7]="DWLBD108"
JBLIST_FULL[8]="DWLBD109"
JBLIST_FULL[9]="DWLBD110"
JBLIST_FULL[10]="BLLBD201"
JBLIST_FULL[11]="DWLBD202"
JBLIST_FULL[12]="DWLBD203"
JBLIST_FULL[13]="DWLBD204"
JBLIST_FULL[14]="DWLBD205"
JBLIST_FULL[15]="DWLBD206"
JBLIST_FULL[16]="BLLBD301"
JBLIST_FULL[17]="DWLBD302"
JBLIST_FULL[18]="DWLBD303"
JBLIST_FULL[19]="DWLBD304"
JBLIST_FULL[20]="DWLBD305"
JBLIST_FULL[21]="DWLBD306"
JBLIST_FULL[22]="DWLBD307"
JBLIST_FULL[23]="BLLBD401"
JBLIST_FULL[24]="DWLBD402"
JBLIST_FULL[25]="DWLBD403"
JBLIST_FULL[26]="DWLBD404"
JBLIST_FULL[27]="DWLBD405"
JBLIST_FULL[28]="DWLBD406"
#---------------------------------------------------------------#
for JOB in "${JBLIST_FULL[@]}"
do
jb_rtv_date1=$(grep -A3 "$JOB" "$RTVIEW" | tail -1 | tr '[<>]' ' '| awk '{print $5}')
jb_rtv_time1=$(grep -A3 "$JOB" "$RTVIEW" | tail -1 | tr '[<>]' ' '| awk '{print $6}')
jb_rtv_status=$(grep -A3 "$JOB" "$RTVIEW" | tail -1 | tr '[<>]' ' '|awk -F ' ' '{ print $2,$3 }')
jb_rtv_day=$(grep -A3 "$JOB" "$RTVIEW" | tail -1 | tr '[<>]' ' '| awk '{print $4}')
jb_rtv_hour=$(grep -A3 "$JOB" "$RTVIEW" | tail -1 | tr '[<>]' ' '| awk '{print $6}'|cut -c1-2)
jb_rtv_min=$(grep -A3 "$JOB" "$RTVIEW" | tail -1 | tr '[<>]' ' '| awk '{print $6}'|cut -c4-5)
# get specific info from set_schd.cfg
mtchTime=$( grep "$JOB" ${scriptDir}/${set_schd.cfg} | grep "${currTime}" )
# do checks and generate output accordingly
if [[ "${sys_curr_day}" != "Sat" ]] && [[ "${sys_curr_day}" != "Sun" ]]
then
if [[ "${currDate1}" == "${jb_rtv_date1}" ]]
then
if [[ -n "${mtchTime}" ]]
then
echo " ${currTime} is available in configuration file"
jb_exists=$(grep -A3 "$JOB" "$RTVIEW")
if [[ -n "${jb_exists}" ]]
then
echo "$JOB" Entry exists...!!!
if [[ "${currTime}" == "${jb_rtv_time1}" && "${jb_rtv_status}" == "GOOD RUN" ]]
then
echo " entry found in RTView: GREEN...!!!"
set_color "$JOB" "$COLOR_GREEN"
elif [[ "${currTime}" == "${jb_rtv_time1}" && "${jb_rtv_status}}" == "BAD RUN" ]]
then
echo " entry found in RTView: RED...!!!"
set_color "$JOB" "$COLOR_RED"
fi
elif [[ -z "${jb_exists}" ]]
then
echo "$JOB" entry doesn't exist...!!!
echo " entry not found in RTView: RED...!!!"
set_color "$JOB" "$COLOR_RED"
fi
elif [[ -z "${mtchTime}" ]]
then
echo " ${currTime} is not available in configuration file"
if [[ "${currTime}" == "${jb_rtv_time1}" && "${jb_rtv_status}" == "GOOD RUN" ]]
then
echo " entry found in RTView: GREEN...!!!"
set_color "$JOB" "$COLOR_GREEN"
elif [[ "${currTime}" == "${jb_rtv_time1}" && "${jb_rtv_status}" == "BAD RUN" ]]
then
echo " entry found in RTView: RED...!!!"
set_color "$JOB" "$COLOR_RED"
fi
fi
elif [[ "${currDate1}" != "{jb_rtv_date1}" ]]
then
echo "Entry is older..!!"
set_color "$JOB" "$COLOR_GRAY"
fi
fi
done