ReachableCEO-ShellScriptPor.../NetworkManagement/librenmsPollScripts/pollerWrapCommon.sh

28 lines
1.0 KiB
Bash
Raw Normal View History

2024-12-13 23:32:49 +00:00
function error_out()
#Handle error conditions
#Takes two arguments:
#Error type (fatal,nonfatal)
#Error message
{
if [ $1 == "fatal" ]; then
echo "$0 has experienced a fatal error condition and has aborted operation at $DATE. Please investigate and resolve. Details: $2" | mail -s "Observium polling fatal error" -r $ERROR_FROM $ERROR_TO
logger $0 has experienced a fatal error condition and has aborted operation at $DATE. Details: $2
exit 1
elif [ $1 == "nonfatal" ]; then
echo "$0 has experienced a non fatal error condition and has continued operation at $DATE. Please investigate and resolve. \n Details: $2" | mail -s "Observium polling non fatal error" -r $ERROR_FROM $ERROR_TO
logger $0 has experienced a non fatal error condition and has continued operation at $DATE . Details: $2
fi
}
function preflight()
#Perform preflight checks for all scan types
{
echo "Performing preflight checks for polling of: $1"
logger "Performing preflight checks for polling of: $1"
if [ -f /tmp/poll-$1.lock ]; then
error_out fatal "Poll lock file /tmp/poll-$1.lock exists."
fi
}