2009-03-29 05:01:25 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
START=90
|
2009-06-10 14:37:36 +00:00
|
|
|
EXPORTER=/usr/sbin/wprobe-ipfix
|
2009-03-29 05:01:25 +00:00
|
|
|
|
|
|
|
wprobe_ssd() {
|
|
|
|
local cfg="$1"; shift
|
|
|
|
local cmd="$1"; shift
|
2009-06-10 14:37:36 +00:00
|
|
|
start-stop-daemon "$cmd" -p "/var/run/wprobe-$cfg.pid" -b -x "$EXPORTER" -m -- "$@"
|
2009-03-29 05:01:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop_wprobe() {
|
|
|
|
local cfg="$1"
|
|
|
|
[ -f "/var/run/wprobe-$cfg.pid" ] && wprobe_ssd "$cfg" -K
|
|
|
|
rm -f "/var/run/wprobe-$cfg.pid"
|
|
|
|
}
|
|
|
|
|
2009-06-10 14:37:36 +00:00
|
|
|
config_wprobe() {
|
|
|
|
config_get ifname "$cfg" ifname
|
|
|
|
config_get interval "$cfg" interval
|
|
|
|
[ -n "$interval" ] || interval=100
|
|
|
|
wprobe-info "$ifname" -c -i "$interval"
|
|
|
|
}
|
|
|
|
|
|
|
|
start_ipfix() {
|
2009-03-29 05:01:25 +00:00
|
|
|
local cfg="$1"
|
|
|
|
config_get ifname "$cfg" interface
|
|
|
|
config_get host "$cfg" host
|
|
|
|
config_get port "$cfg" port
|
|
|
|
config_get proto "$cfg" proto
|
|
|
|
case "$proto" in
|
|
|
|
sctp) proto="-s";;
|
|
|
|
tcp) proto="-t";;
|
|
|
|
udp) proto="-u";;
|
|
|
|
*) proto="-t";;
|
|
|
|
esac
|
|
|
|
[ -z "$ifname" -o -z "$host" ] && {
|
|
|
|
echo "wprobe-export: missing host or interface name in config $cfg"
|
|
|
|
return
|
|
|
|
}
|
2009-06-10 14:37:36 +00:00
|
|
|
config_wprobe "$cfg"
|
2009-03-29 05:01:25 +00:00
|
|
|
wprobe_ssd "$cfg" -S "$proto" -i "$ifname" -c "$host" -p "${port:-4739}"
|
|
|
|
}
|
|
|
|
|
2009-06-10 14:37:36 +00:00
|
|
|
start_export() {
|
|
|
|
config_get export_type "$cfg" type
|
|
|
|
case "$export_type" in
|
|
|
|
ipfix) start_ipfix "$cfg";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2009-03-29 05:01:25 +00:00
|
|
|
stop() {
|
|
|
|
for f in /var/run/wprobe-*.pid; do
|
|
|
|
CFG="${f%%.pid}"
|
|
|
|
CFG="${CFG##/var/run/wprobe-}"
|
|
|
|
stop_wprobe "$CFG"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
config_load wprobe
|
2009-06-10 14:37:36 +00:00
|
|
|
config_foreach config_wprobe interface
|
|
|
|
[ -x "$EXPORTER" ] && config_foreach start_export export
|
2009-03-29 05:01:25 +00:00
|
|
|
}
|