Forum Discussion

schmuck's avatar
schmuck
Icon for Nimbostratus rankNimbostratus
Apr 06, 2016

Notifications via External Monitor

Hi, I have an external monitor that sends a notification (email) when it fails. I don't want it failing so I just had it create a file when if fails. If that file doesn't exist, it will notify. If it does exist, it just marks it down but doesn't send the alert. The way I thought to clean it up was just to rm-f the file when the status goes back to UP. This works fine if the script is run manually, but will not work when it runs through F5. Here are the basics of the script:

curl -s -v -k -H "Host: ${HOST}" -k https://${NODE}${URI} 2>&1 > /dev/null | grep -i "${RECV}"
STATUS=$?
rm -f $PIDFILE
if [ $STATUS -eq 0 ]
then
    rm -f /shared/tmp/service-${NODE}
    echo "UP"
else
   if [ ! -f /shared/tmp/service-${NODE} ]
   then
      touch /shared/tmp/service-${NODE}
      chmod 777 /shared/tmp/service-${NODE}
      curl -s -o /shared/tmp/service-${NODE}.html -H "Host: ${HOST}" -k https://${NODE}${URI}

   EMAIL NOTIFICATION PART
   fi
fi
exit

Is there something that I am missing? Is there a better way?

  • Can you clarify what you mean by "will not work" when run as an EAV ? Do you mean that the semaphore file isn't deleted, or is it that it isn't created and you get continuous emails, or something else ? Also, rather than running curl a second time if the monitor fails, I would grab the output in the first curl, and store that in a variable to be written to the .html file on failure, just in case the pool member's output has changed between the first and second instance or curl.