Is there tool or a command that helps capture the bandwidth consumption of specific process (PID), just like the System Monitor does, but for a single specific process, as shows the following screenshot 
I will be happy with a command line tool that at least exports such history to files. (I'm on Ubuntu 16.04)
Update 1
I want at least a tool like Nethogs that can output into files (Nethogs captures only TCP connexions) a similar tool that targets both TCP and UDP would be great
Update 2
Any script, combination of other tools (like wireshark) would help too.