net/lsm: add link state monitor package. (thank you Brian J. Murrell)
[openwrt/svn-archive/archive.git] / net / lsm / files / lsm_script
1 #!/bin/sh
2 #
3 # (C) 2009 Mika Ilmaranta <ilmis at nullnet.fi>
4 #
5 # License: GPLv2
6 #
7
8 #
9 # default event handling script
10 #
11
12 DATE=$(/bin/date)
13
14 STATE=${1}
15 NAME=${2}
16 CHECKIP=${3}
17 DEVICE=${4}
18 WARN_EMAIL=${5}
19 REPLIED=${6}
20 WAITING=${7}
21 TIMEOUT=${8}
22 REPLY_LATE=${9}
23 CONS_RCVD=${10}
24 CONS_WAIT=${11}
25 CONS_MISS=${12}
26 AVG_RTT=${13}
27
28 cat <<EOM | mail -s "LSM: ${NAME} ${STATE}, IP ${CHECKIP}" ${WARN_EMAIL}
29
30 Hi,
31
32 Your connection ${NAME} has changed it's state to ${STATE} at ${DATE}.
33
34 Following parameters were passed:
35 newstate = ${STATE}
36 name = ${NAME}
37 checkip = ${CHECKIP}
38 device = ${DEVICE}
39 warn_email = ${WARN_EMAIL}
40
41 Packet statuses:
42 replied = ${REPLIED} packets replied
43 waiting = ${WAITING} packets waiting for reply
44 timeout = ${TIMEOUT} packets that have timeout (= packet loss)
45 reply_late = ${REPLY_LATE} packets that received a reply after timeout
46 cons_rcvd = ${CONS_RCVD} consecutively received replies in sequence
47 cons_wait = ${CONS_WAIT} consecutive packets waiting for reply
48 cons_miss = ${CONS_MISS} consecutive packets that have timed out
49 avg_rtt = ${AVG_RTT} average rtt [usec], calculated from received packets
50
51 BR,
52 Your LSM installation
53
54 EOM
55
56 cd /etc/lsm/script.d/
57 for script in $(ls); do
58 if [ ! -x $script ]; then
59 continue
60 fi
61 ./$script "$@"
62 done
63
64 exit 0;
65
66 #EOF