#!/bin/sh # PROVIDE: ngnetflow # REQUIRE: netif # KEYWORD: nojail shutdown . /etc/rc.subr name="ngnetflow" rcvar=`set_rcvar` start_cmd="${name}_start" stop_cmd=":" load_rc_config $name eval "${rcvar}=\${${rcvar}:-'NO'}" ngnetflow_ifaces=${ngnetflow_ifaces:-""} ngnetflow_export=${ngnetflow_export:-""} ngnetflow_start() { if [ -z "${ngnetflow_ifaces}" ]; then echo "ngnetflow_ifaces not set" return 1 fi if [ -z "${ngnetflow_export}" ]; then echo "ngnetflow_export not set" return 1 fi count_if="0" for iface in ${ngnetflow_ifaces}; do ngctl mkpeer ${iface}: tee lower left ngctl name ${iface}:lower ${iface}_tee ngctl connect ${iface}: ${iface}_tee: upper right ngctl mkpeer ${iface}_tee: one2many left2right many0 ngctl name ${iface}_tee:left2right ${iface}_tee_o2m ngctl connect ${iface}_tee: ${iface}_tee_o2m: right2left many1 if [ "${count_if}" -eq "0" ]; then ngctl mkpeer ${iface}_tee_o2m: netflow one iface0 ngctl name ${iface}_tee_o2m:one netflow else ngctl connect ${iface}_tee_o2m: netflow: one iface${count_if} fi count_if=`echo ${count_if} | awk '{ $0++; print $0; }'` done ngctl mkpeer netflow: ksocket export inet/dgram/udp ngctl name netflow:export nf_ksocket ngctl msg nf_ksocket: connect inet/${ngnetflow_export} echo "Netflow system started..." return 0 } run_rc_command "$1"