ar71xx: ag71xx: use dynamically allocated buffer for napi_stats
[openwrt.git] / package / wprobe / files / wprobe.init
1 #!/bin/sh /etc/rc.common
2 START=90
3 EXPORTER=/sbin/wprobe-export
4 UTIL=/sbin/wprobe-util
5
6 wprobe_ssd() {
7 local cmd="$1"; shift
8 local type="$1"; shift
9 local app="$1"; shift
10 start-stop-daemon "$cmd" -p "/var/run/wprobe-$type.pid" -b ${app:+-x "$app"} -m -- "$@"
11 }
12
13 stop_wprobe() {
14 local type="$1"
15 [ -f "/var/run/wprobe-$type.pid" ] && wprobe_ssd -K "$type"
16 rm -f "/var/run/wprobe-$type.pid"
17 }
18
19 config_wprobe() {
20 config_get ifname "$cfg" ifname
21 config_get interval "$cfg" interval
22 [ -n "$interval" ] || interval=100
23 $UTIL "$ifname" -i "$interval" 2>/dev/null >/dev/null
24 }
25
26 start_proxy() {
27 config_get port "$cfg" port
28 wprobe_ssd -S proxy "$UTIL" -P -p "${port:-17990}"
29 }
30
31 start_ipfix() {
32 local cfg="$1"
33 config_get ifname "$cfg" ifname
34 config_get host "$cfg" host
35 config_get port "$cfg" port
36 config_get proto "$cfg" proto
37 case "$proto" in
38 sctp) proto="-s";;
39 tcp) proto="-t";;
40 udp) proto="-u";;
41 *) proto="-t";;
42 esac
43 [ -z "$ifname" -o -z "$host" ] && {
44 echo "wprobe-export: missing host or interface name in config $cfg"
45 return
46 }
47 config_wprobe "$cfg"
48 wprobe_ssd -S "export-$cfg" "$EXPORTER" "$proto" -i "$ifname" -c "$host" -p "${port:-4739}"
49 }
50
51 start_export() {
52 local cfg="$1"
53 config_get export_type "$cfg" type
54 case "$export_type" in
55 ipfix) [ -x "$EXPORTER" ] && start_ipfix "$cfg";;
56 wprobe) start_proxy "$cfg";;
57 esac
58 }
59
60 stop() {
61 for f in /var/run/wprobe-*.pid; do
62 CFG="${f%%.pid}"
63 CFG="${CFG##/var/run/wprobe-}"
64 stop_wprobe "$CFG"
65 done
66 }
67
68 start() {
69 config_load wprobe
70 config_foreach config_wprobe interface
71 config_foreach start_export export
72 }
This page took 0.042235 seconds and 5 git commands to generate.