Monday, April 13, 2009

Детальна статистика на FreeBSD-7 за допомогою Netflow

#cd /usr/ports/net-mgmt/softflowd
#make install

#cat >> /etc/rc.conf
softflowd_enable="YES"
softflowd_interfaces="ste0"
softflowd_netflow_host="127.0.0.1"
softflowd_netflow_port="8787"

#cat >> /usr/local/etc/rc.d/softflowd

#!/bin/sh


# Set this rc.conf variables
# * softflowd_enable - enable softflowd?
# * softflowd_interfaces - interfaces to listen
# * softflowd_netflow_host - collector host
# * softflowd_netflow_port - collector port
# in rc.conf variables
# Example:
# softflowd_interfaces="em0 em1 xl0"
# softflowd_netflow_host=
# softflowd_netflow_port=


. /etc/rc.conf

if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
echo "$0: Cannot determine the PREFIX" >&2
exit 1
fi

echo "$softflowd_enable" | grep -qix yes || exit
[ -z "$softflowd_interfaces" ] && exit

[ -x ${PREFIX}/sbin/softflowd ] || exit
SOFTFLOWD=${PREFIX}/sbin/softflowd
SOFTFLOWCTL=${PREFIX}/sbin/softflowctl

case "$1" in
start)
for interface in ${softflowd_interfaces}
do
${SOFTFLOWD} -i ${interface} -n "$softflowd_netflow_host":"$softflowd_netflow_port"
echo -n softflowd[$interface]" "
softflowd_netflow_port="`expr $softflowd_netflow_port + 1`"
done
;;
stop)
${SOFTFLOWCTL} shutdown && echo -n ' softflowd'
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
;;
esac

exit 0


#chmod u+x /usr/local/etc/rc.d/softflowd

# /usr/local/etc/rc.d/softflowd start


2. Встановлюємо і налаштовуємо коллектор flow-tools
# cd /usr/ports/net-mgmt/flow-tools
# make install

в rc.conf дописуємо

flow_capture_enable="YES"
flow_capture_datadir="/var/db/flows"
flow_capture_localip="127.0.0.1"
flow_capture_remoteip="127.0.0.1"
flow_capture_port="8787"
flow_capture_pid="/var/run/flow-capture/flow-capture.pid"
flow_capture_user="flowtools"
flow_capture_group="flowtools"
flow_capture_flags="-E 128M"


і запускаємо
/usr/local/etc/rc.d/flow_capture start

No comments: