Commit 6ab92467 authored by Ad Schellevis's avatar Ad Schellevis

(netflow) finish rc scripting

parent b706112a
# Sample configuration for netflow daemon (/usr/local/etc/netflow.conf)
# The configuration below sends flows captured from em0 and em1 to multiple locations
# define interfaces to configure # define interfaces to configure
netflow_interfaces="em0 em1" netflow_interfaces="em0 em1"
# per interface settings # per interface settings
# netflow_<interface>_int_destination -> address:port # netflow_<interface>_int_destination -> address:port
netflow_em0_int_destination="127.0.0.1:3001" netflow_em0_int_destination="127.0.0.1:3001"
netflow_em1_int_destination="127.0.0.1:3002"
# netflow_<interface>_destinations -> address:port address:port ... # netflow_<interface>_destinations -> address:port address:port ...
netflow_em0_destinations="10.211.55.101:2055 10.211.55.100:4444" netflow_em0_destinations="10.211.55.101:2055 10.211.55.100:4444"
netflow_em1_destinations="10.211.55.101:2056"
...@@ -62,12 +62,17 @@ setup_interface() ...@@ -62,12 +62,17 @@ setup_interface()
SEQ SEQ
# forward netflow packets, make sure $netflow_int_destination forwards to localhost (127.0.0.1) # forward netflow packets, make sure $netflow_int_destination forwards to localhost (127.0.0.1)
if [ "$destinations" != "" ]; then if [ "$destinations" != "" ]; then
/usr/local/bin/samplicate -s 127.0.0.1 -f -p $netflow_port $destinations /usr/sbin/daemon -p /var/run/netflow_samplicate_$interface -u nobody /usr/local/bin/samplicate -s 127.0.0.1 -p $netflow_port $destinations
fi fi
} }
netflow_start() netflow_start()
{ {
is_running=`ngctl list | grep netflow_ | wc -l`
if [ $is_running -ne 0 ]; then
echo "already running"
return
fi
for interface in $netflow_interfaces for interface in $netflow_interfaces
do do
int_destination="netflow_"$interface"_int_destination" int_destination="netflow_"$interface"_int_destination"
...@@ -80,9 +85,21 @@ netflow_start() ...@@ -80,9 +85,21 @@ netflow_start()
done done
} }
# stop netflow collect and distribution
netflow_stop() netflow_stop()
{ {
#todo # kill all samplicate processes
for samplicate_pid in `ls /var/run/netflow_samplicate_* 2>/dev/null`
do
kill -9 `cat $samplicate_pid`
done
# cleanup netflow processes
for netflow_node in `ngctl list | grep netflow_ | awk '{print $2;}'`
do
/usr/sbin/ngctl shutdown $netflow_node:
done
} }
load_rc_config $name load_rc_config $name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment