1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add option to send mail when connection status change

This commit is contained in:
Ycarus 2018-11-05 19:14:23 +01:00
parent 80cb838778
commit 2679958caa
9 changed files with 155 additions and 0 deletions

View file

@ -122,10 +122,14 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
exit 0
fi
[ "$multipath_status" = "off" ] || {
mail_alert="$(uci -q get omr-tracker.$OMR_TRACKER_INTERFACE.mail_alert)"
[ -z "$mail_alert" ] && mail_alert="$(uci -q get omr-tracker.defaults.mail_alert)"
if [ "$OMR_TRACKER_STATUS_MSG" = "" ]; then
_log "$OMR_TRACKER_DEVICE switched off"
[ "$mail_alert" = "1" ] && echo -e "Subject: OpenMPTCProuter: $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is down\n\nOpenMPTCProuter detected a connection failure of $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE)." | sendmail $(uci -q get mail.default.to)
else
_log "$OMR_TRACKER_DEVICE switched off because $OMR_TRACKER_STATUS_MSG"
[ "$mail_alert" = "1" ] && echo -e "Subject: OpenMPTCProuter: $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is down\n\nOpenMPTCProuter detected a connection failure of $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE). The reason is \"$OMR_TRACKER_STATUS_MSG\"." | sendmail $(uci -q get mail.default.to)
fi
if [ "$(sysctl -n net.mptcp.mptcp_enabled | tr -d '\n')" = "1" ]; then
multipath "$OMR_TRACKER_DEVICE" off > /dev/null 2>&1
@ -213,6 +217,12 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
exit 0
fi
if [ "$OMR_TRACKER_PREV_STATUS" != "" ] && [ "$OMR_TRACKER_PREV_STATUS" != "$OMR_TRACKER_STATUS" ]; then
mail_alert="$(uci -q get omr-tracker.$OMR_TRACKER_INTERFACE.mail_alert)"
[ -z "$mail_alert" ] && mail_alert="$(uci -q get omr-tracker.defaults.mail_alert)"
[ "$mail_alert" = "1" ] && echo -e "Subject: OpenMPTCProuter: $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is down\n\nOpenMPTCProuter detected a connection failure of $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE)." | sendmail $(uci -q get mail.default.to)
fi
multipath_config=$(uci -q get "network.$OMR_TRACKER_INTERFACE.multipath" || echo "off")
if [ "$multipath_config" = "master" ]; then
if [ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]; then