#!/bin/sh
#
#	trafsave	Copyright (c)1993 CAD lab
#
#	backup(append) all records to /var/log/trafd.$iface
#	and restart collect network traffic again
#
# usage: trafsave interfaces...
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
WHERE_PID=/var/run/trafd.
LOG_FILE=/var/log/traffic.log

if [ $# = 0 ]; then
	echo trafsave - save tcp/udp network data traffic
	echo usage: trafsave interfaces...
	exit 1
fi

for iface in $*; do
	PID_FILE=$WHERE_PID$iface
	if [ -f $PID_FILE ]; then
		kill -INT `cat $PID_FILE`
		if [ $? = 0 ]; then
			echo `date +"%b %e %H:%M:%S"` `hostname -s` trafsave: \
'('$iface')' signaling to backup >> $LOG_FILE
		fi
	else
		echo error: $PID_FILE not found | tee -a $LOG_FILE
	fi
done
