Skip to content

Commit

Permalink
Improved check script and added utils.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
meg-hox committed Mar 14, 2024
1 parent c30f10e commit 67a190f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 14 deletions.
51 changes: 47 additions & 4 deletions check_v4.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

source ~/.bash_profile
##########################################
#
# Paths and routes
Expand All @@ -26,7 +27,7 @@ ERR_PATH=$OP_PATH/logs/err
# Load utils
#
##########################################

echo "source ${OP_PATH}/utils.sh"
source ${OP_PATH}/utils.sh


Expand Down Expand Up @@ -134,9 +135,51 @@ for COMP in ${COMPONENTS[@]}; do
esac
else

echo "LOG file not ready yet."
echo "job still to complete! Exiting..."
exit
echo "LOG file not ready."
# JOBS=$(bjobs )#| wc -l)


JOBS=$(bjobs -o "JOB_NAME" -noheader | grep -v grep | wc -l )
JOBS_RUN=$(bjobs -o "STAT" -noheader | grep RUN | wc -l )
JOBS_PEND=$(bjobs -o "STAT" -noheader | grep PEND | wc -l )
echo "JOBS are $JOBS"
echo "Running jobs are $JOBS_RUN"
echo "Pending jobs are $JOBS_PEND"

if [[ "$JOBS_RUN" -ge "1" ]] ; then
echo " -- Because job still in progress ($JOBS_RUN)"
exit
else
# if [[ "$JOBS_PEND" -ge "1" ]]; then
# echo " -- Because jobs are in PENDING."
# echo "Let's see the components."
# else
# echo " -- Because no jobs in the crontab"
# exit
# fi

# if there are pending jobs, see the previous job if end SUCCESFULLY or NOT.
# IF PREV JOB END SUCCES -> wait
# IF PREV JOB END WITH EXIT -> send notify

if [[ "$JOBS_PEND" -ge "1" ]]; then

PREV_JOB=$(bjobs -a | tail -n 1 | grep "DONE" | wc -l)
if [[ "$PREV_JOB" -ge "1" ]] ; then
echo " -- Previous job ended succesfully, waiting the end of the pending jobs ($JOBS_PEND)."
exit
else
echo " -- Previous job ended with an error. Send notify."
echo "Let's see the components."
fi

else
echo " -- Because there are no jobs to do"
exit
fi

fi

fi

done
Expand Down
20 changes: 10 additions & 10 deletions utils.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# read configuration file
source $HOME/.telegramrc

# source $HOME/.telegramrc
source /users_home/opa/visir-dev/.telegramrc_frame

####################################################
#
Expand All @@ -27,17 +27,17 @@ Notify() {

echo "[$APPNAME] $msg" 2>&1 | tee -a $LOGFILE
if [[ $msgType -eq 0 ]]; then
if [[ ${TELEGRAM_ENABLED} ]]; then
if [[ ${TELEGRAM_ENABLED} ]]; then
sh ${TELEGRAM_EXE} -t ${TELEGRAM_TOKEN} -c ${TELEGRAM_CHANNEL} "[$app] $(echo -e '\U0000274C') $msg"
fi
fi
elif [[ $msgType -eq 1 ]]; then
if [[ ${TELEGRAM_ENABLED} ]]; then
sh ${TELEGRAM_EXE} -t ${TELEGRAM_TOKEN} -c ${TELEGRAM_CHANNEL} "[$app] $(echo -e '\U0001F7E2') $msg"
fi
if [[ ${TELEGRAM_ENABLED} ]]; then
sh ${TELEGRAM_EXE} -t ${TELEGRAM_TOKEN} -c ${TELEGRAM_CHANNEL} "[$app] $(echo -e '\U0001F7E2') $msg"
fi
elif [[ $msgType -eq 2 ]]; then
if [[ ${TELEGRAM_ENABLED} ]]; then
sh ${TELEGRAM_EXE} -t ${TELEGRAM_TOKEN} -c ${TELEGRAM_CHANNEL} "[$app] $(echo -e '\U00002699') $msg"
fi
if [[ ${TELEGRAM_ENABLED} ]]; then
sh ${TELEGRAM_EXE} -t ${TELEGRAM_TOKEN} -c ${TELEGRAM_CHANNEL} "[$app] $(echo -e '\U00002699') $msg"
fi
fi

}

0 comments on commit 67a190f

Please sign in to comment.