luci-app-nlbw: fix sporadic premature EOF when rendering JSON data
[project/luci.git] / applications / luci-app-mwan3 / root / etc / hotplug.d / iface / 16-mwancustombak
1 #!/bin/sh
2
3 # to enable this script uncomment the case loop at the bottom
4 # to report mwan status on interface hotplug ifup/ifdown events modify the lines in the send_alert function
5
6 send_alert()
7 {
8         # variable "$1" stores the MWAN status information
9         # insert your code here to send the contents of "$1"
10         echo "$1"
11 }
12
13 gather_event_info()
14 {
15         # create event information message
16         local EVENT_INFO="Interface [ "$INTERFACE" ($DEVICE) ] on router [ "$(uci -p /var/state get system.@system[0].hostname)" ] has triggered a hotplug [ "$ACTION" ] event on "$(date +"%a %b %d %Y %T %Z")""
17
18         # get current interface, policy and rule status
19         local CURRENT_STATUS="$(/usr/sbin/mwan3 status)"
20
21         # get last 50 MWAN systemlog messages
22         local MWAN_LOG="$(echo -e "Last 50 MWAN systemlog entries. Newest entries sorted at the top:\n$(logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x')")"
23
24         # pass event info to send_alert function
25         send_alert "$(echo -e "$EVENT_INFO\n\n$CURRENT_STATUS\n\n$MWAN_LOG")"
26 }
27
28 #case "$ACTION" in
29 #       ifup)
30 #               gather_event_info
31 #       ;;
32 #
33 #       ifdown)
34 #               gather_event_info
35 #       ;;
36 #esac
37
38 exit 0