Sunday, 15 September 2013

parse byte count in ftp log

parse byte count in ftp log

I'm running on an arm architecture. Should be a bash script. I would like
to graph total bytes coming and out of my ftp server.
I parse the ftp.log file with this command to get this output:
`cat ftp.log | grep loaded`
the interesting lines are in this format:
Sep 14 18:46:00 sharecenter pure-ftpd: (doc@omega) [NOTICE]
/mnt/HD/HD_a2//SAVE/backupffp.sh downloaded (423 bytes, 0.78KB/sec) Sep 15
22:06:47 sharecenter pure-ftpd: (doc@omega) [NOTICE]
/mnt/HD/HD_a2//SAVE/ffp-2013-09-14.tar.bz2 downloaded (904753213 bytes,
1928.17KB/sec) Sep 15 22:32:26 sharecenter pure-ftpd: (doc@omega) [NOTICE]
/mnt/HD/HD_a2//SAVE/test.avi uploaded (576711530 bytes, 1465.80KB/sec)
Now I need to get the values after the "(" and before the word "bytes" and
add them.
Example:
--> downloaded 423+904753213=904753636 => returned value: 904753636
--> uploaded 576711530 => returned value: 576711530
Now the script will run every 5 minutes, so the result has to take into
account only the numbers between the last 5 minutes. Example: At 22:05
script runs and adds all bytes. When script runs again at 22:10 only the
transfered bytes between 22:05 to 22:10 should be added.
For rrd you need a simple output, 2 variables "dowloaded" and "uploaded".
So I will need those 2 values in those 2 variables.
I hope I am clear enough, if not don't hesitate to ask for more information.
Many thanks for your help.

No comments:

Post a Comment