#!/bin/sh
#
#	trafstart	Copyleft (c)2001 Grumbler
#
#	start of the network traffic collector
#


LOG_FILE=/var/log/trafd.log

if [ $# = 0 ]; then
  if [ "_$IFF_LISTEN"="_" ]; then
	echo trafstart - start tcp/udp network data traffic collector
	echo usage:
	echo "      trafstart interface1 [interface2 ...]"
	echo "      trafstart all"
	echo "or set the enviroment variable IFF_LISTEN to interface name"
	echo "and run without parameters"
	exit 1
  else
	ifaces="$IFF_LISTEN"	
  fi
else
  if [ "$1_" = "all_" ] ; then
	ifaces="`ifconfig -lu | sed s/lo0//`"
  else
	ifaces="$*"
  fi
fi

for iface in ${ifaces} ; do
  /usr/local/sbin/trafd -pri ${iface} && echo " trafd(${iface}) "
  if [ $? = 0 ]; then
    echo `date +"%b %e %H:%M:%S"` `hostname -s` trafd.sh: '('$iface')' started >> $LOG_FILE
  fi
done

