Mwan3 notifcation script

Total NOOB, I know I must have done something wrong as this does not work. On any event that calls the mwan3 notification script, the script should email me stating which $DEVICE $INTERFACE $ACTION. I have tried sending an email with just the contence of test but with no avail.

Info from the mwan3 load balancing package Notifcation tab

MWAN - Notification

This section allows you to modify the content of "/etc/mwan3.user".
The file is also preserved during sysupgrade.

Notes:
This file is interpreted as a shell script.
The first line of the script must be "#!/bin/sh" without quotes.
Lines beginning with # are comments and are not executed.
Put your custom mwan3 action here, they will
be executed with each netifd hotplug interface event
on interfaces for which mwan3 is enabled.

There are three main environment variables that are passed to this script.

$ACTION

  • "ifup" Is called by netifd and mwan3track
  • "ifdown" Is called by netifd and mwan3track
  • "connected" Is only called by mwan3track if tracking was successful
  • "disconnected" Is only called by mwan3track if tracking has failed
    $INTERFACE Name of the interface which went up or down (e.g. "wan" or "wwan")
    $DEVICE Physical device name which interface went up or down (e.g. "eth0" or "wwan0")

--EDIT--
This is the currently working script as noted in solution requires chmod +x to permit the mwan3.user to run.

#!/bin/sh
mailsend -f ####### -t ####### -starttls -port 587 -auth -smtp smtp.gmail.com -sub "Connection Alert" -M "$DEVICE $INTERFACE $ACTION" +cc +bc -v -user "###########" -
pass "#####"

For some reason this was a permissions issue and the pre-generated file from mwan3 was not able to be run.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.