#!/bin/bash
LOGFILE=/var/log/flow/flow_profile.log
to_ftp()
{
now=$(date +%d.%m.%Y_%H-%M-%S)
ftp -ivn webdb.vvsu.ru <<ENDFTP
user netflow numikafros
passive
binary
cd VPNLog
lcd /tmp
put flowout.csv flow-${now}.csv
bye
ENDFTP
}
echo "start $(date +%d.%m.%Y_%H-%M-%S)" >>$LOGFILE
#flow-cat /var/flow/ft-v05.* | flow-export -f 2 > `date +%Y-%m-%d-%H-%M-%S`.csv
flow-cat $1 | flow-export -f 2 > /tmp/flowout.csv 2>>$LOGFILE
echo "exported $(date +%d.%m.%Y_%H-%M-%S)" >>$LOGFILE 
to_ftp
echo "uploaded $(date +%d.%m.%Y_%H-%M-%S)" >>$LOGFILE
rm -f $1
echo "deleted $(date +%d.%m.%Y_%H-%M-%S)" >>$LOGFILE
