You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

  1. #!/bin/sh
  2. # to enable this script uncomment the case loop at the bottom
  3. # to report MWAN3 status on interface up/down events modify the lines in the send_reportdata function
  4. send_alert()
  5. {
  6. # $1 stores the mwan3 status information
  7. # insert your code here to send the contents of $1
  8. echo "$1"
  9. }
  10. gather_event_info()
  11. {
  12. # create event information message
  13. local EVENT_INFO="Interface [ "$INTERFACE" ($DEVICE) ] on router [ "$(uci get -p /var/state system.@system[0].hostname)" ] has triggered an [ "$ACTION" ] hotplug event on "$(date)""
  14. # get current interface, policy and rule status
  15. local CURRENT_STATUS="$(mwan3 status)"
  16. # get last 50 mwan3 systemlog messages
  17. local MWAN3_LOG="$(echo -e "Last 50 MWAN3 systemlog entries. Newest entries sorted at the top:\n$(logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x')")"
  18. # pass event info to send_alert function
  19. send_alert "$(echo -e "$EVENT_INFO\n\n$CURRENT_STATUS\n\n$MWAN3_LOG")"
  20. }
  21. #case "$ACTION" in
  22. # ifup)
  23. # gather_event_info
  24. # ;;
  25. #
  26. # ifdown)
  27. # gather_event_info
  28. # ;;
  29. #esac
  30. exit 0