Skip to content

Instantly share code, notes, and snippets.

@saurabh2590
Created September 20, 2022 09:02
Show Gist options
  • Save saurabh2590/58cf552bc0228b9b3edb0c1c59dc250f to your computer and use it in GitHub Desktop.
Save saurabh2590/58cf552bc0228b9b3edb0c1c59dc250f to your computer and use it in GitHub Desktop.
Why SMS are not sent for unknown state
# Do not alert state UNKKNOWN
if [[ "${TYPE}" == "PROBLEM" && "${STATE}" == "UNKNOWN" ]] ; then
EMAIL=false
SMS=false
X_SERVICE=$(echo "${SERVICE}" | tr -d '/')
# Safe host and service in ${UNKNOWN_STATE} file
echo "${HOST}: ${X_SERVICE}" >> ${UNKNOWN_STATE}
fi
# Remove host and service from ${UNKNOWN_STATE} file in case of new PROBLEM
if [[ "${TYPE}" == "PROBLEM" && "${STATE}" != "UNKNOWN" ]] ; then
X_SERVICE=$(echo "${SERVICE}" | tr -d '/')
grep "^${HOST}: ${X_SERVICE}$" ${UNKNOWN_STATE} > /dev/null 2>&1
if [ $? -eq 0 ] ; then
sed -i "/^${HOST}: ${X_SERVICE}$/d" ${UNKNOWN_STATE}
fi
fi
# Don't send RECOVERY when last state was UNKNOWN
# Remove host and service from ${UNKNOWN_STATE} file
if [ "${TYPE}" == "RECOVERY" ] ; then
X_SERVICE=$(echo "${SERVICE}" | tr -d '/')
grep "^${HOST}: ${X_SERVICE}$" ${UNKNOWN_STATE} > /dev/null 2>&1
if [ $? -eq 0 ] ; then
EMAIL=false
SMS=false
sed -i "/^${HOST}: ${X_SERVICE}$/d" ${UNKNOWN_STATE}
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment