something to get you started (just in case you want to write it yourself):
#!/bin/bash # # usage: bwmon PID IN=0 OUT=0 IN=0; OUT=0; TIME=0 get_traffic() { t=`awk '/eth0:/ { printf("%s,%d,%d\n",strftime("%s"),$2,$10); }' < /proc/$1/net/dev` IN=${t#*,}; IN=${IN%,*} OUT=${t##*,}; TIME=${t%%,*}; } get_traffic $1 while true do _IN=$IN _OUT=$OUT _IN=$IN; _OUT=$OUT; _TIME=$TIME get_traffic $1 echo "$TIME,$(( $TIME - $_TIME )),$IN,$(( $IN - $_IN )),$OUT,$(( $OUT - $_OUT))" sleep 1 done comments:
- checks only eth0
- checks every 1 second
- works only under linux, but other unixes work similar (procfs or whatever)
- output could be stored into a sqlite.db with
stat --printf="%N\n" /proc/PID/exe | cut -d ' ' -f 3