I probably read all the threads in almost all the forums for a solution to my need. I am a beginner in shell scripting and I dont have a perfect solution yet. Below is my code snippet.
idql -n $REPOSITORY_NAME.$cs -Udmadmin -P"" -R$DM_SCRIPTS/test.api > /dev/null 2>&1 if [ $? != 0 ]; then echo " \c" echo "ERROR: Cannot connect to: $REPOSITORY_NAME.$cs on $HOST" else echo " Successfully connected to: $REPOSITORY_NAME.$cs" fi
This is from the main logic that we use for monitoring our service. But we often see our service getting hung and so the first line of the above snippet gets hung and it doesnt proceed after that. Due to this we are not able to catch this 'service hung' condition.
Most importantly we have to retain the checks for the existing conditions (specified in the if-else conditional statements) and additionally we have to be checking for the 'hung' state. If the
idql command takes more than 5 seconds, we can assume that it is hung.