Monitor network traffic âduring a specific timeâ in linux


up vote
3
down vote
favorite
I need to measure network usage on a specific interface during a specific time. I'm doing some experiments on an application so I need to know how much data is being passed around on a specific interface. So things go like:
1- start recording network usage
2- start the program
3- end the program
4- stop recording network usage
I know tools like vnstat and nload exist, but they don't seem to have the feature I need
networking
add a comment |Â
up vote
3
down vote
favorite
I need to measure network usage on a specific interface during a specific time. I'm doing some experiments on an application so I need to know how much data is being passed around on a specific interface. So things go like:
1- start recording network usage
2- start the program
3- end the program
4- stop recording network usage
I know tools like vnstat and nload exist, but they don't seem to have the feature I need
networking
1
Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at/proc/net/dev
with network stats for each interface including bytes received and transmitted.
â dsstorefile1
Mar 4 at 0:52
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I need to measure network usage on a specific interface during a specific time. I'm doing some experiments on an application so I need to know how much data is being passed around on a specific interface. So things go like:
1- start recording network usage
2- start the program
3- end the program
4- stop recording network usage
I know tools like vnstat and nload exist, but they don't seem to have the feature I need
networking
I need to measure network usage on a specific interface during a specific time. I'm doing some experiments on an application so I need to know how much data is being passed around on a specific interface. So things go like:
1- start recording network usage
2- start the program
3- end the program
4- stop recording network usage
I know tools like vnstat and nload exist, but they don't seem to have the feature I need
networking
networking
asked Mar 4 at 0:48
Manuel
233
233
1
Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at/proc/net/dev
with network stats for each interface including bytes received and transmitted.
â dsstorefile1
Mar 4 at 0:52
add a comment |Â
1
Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at/proc/net/dev
with network stats for each interface including bytes received and transmitted.
â dsstorefile1
Mar 4 at 0:52
1
1
Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at
/proc/net/dev
with network stats for each interface including bytes received and transmitted.â dsstorefile1
Mar 4 at 0:52
Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at
/proc/net/dev
with network stats for each interface including bytes received and transmitted.â dsstorefile1
Mar 4 at 0:52
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
vnstat -l
does do what you need
Simply open a terminal window and type vnstat -l
. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:
$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)
rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C
enp59s0 / traffic statistics
rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds
Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
â Manuel
Mar 4 at 6:12
@Manuel If you are calling it in a script then you would usevnstat -q > starttotal
at start of your script. Do your processing then usevnstat -q > endtotal
. Then parse the two output files to calculateendtotal
-starttotal
=bytesused
.
â WinEunuuchs2Unix
Mar 4 at 12:55
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
vnstat -l
does do what you need
Simply open a terminal window and type vnstat -l
. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:
$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)
rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C
enp59s0 / traffic statistics
rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds
Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
â Manuel
Mar 4 at 6:12
@Manuel If you are calling it in a script then you would usevnstat -q > starttotal
at start of your script. Do your processing then usevnstat -q > endtotal
. Then parse the two output files to calculateendtotal
-starttotal
=bytesused
.
â WinEunuuchs2Unix
Mar 4 at 12:55
add a comment |Â
up vote
1
down vote
accepted
vnstat -l
does do what you need
Simply open a terminal window and type vnstat -l
. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:
$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)
rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C
enp59s0 / traffic statistics
rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds
Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
â Manuel
Mar 4 at 6:12
@Manuel If you are calling it in a script then you would usevnstat -q > starttotal
at start of your script. Do your processing then usevnstat -q > endtotal
. Then parse the two output files to calculateendtotal
-starttotal
=bytesused
.
â WinEunuuchs2Unix
Mar 4 at 12:55
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
vnstat -l
does do what you need
Simply open a terminal window and type vnstat -l
. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:
$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)
rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C
enp59s0 / traffic statistics
rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds
vnstat -l
does do what you need
Simply open a terminal window and type vnstat -l
. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:
$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)
rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C
enp59s0 / traffic statistics
rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds
answered Mar 4 at 3:03


WinEunuuchs2Unix
36k759134
36k759134
Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
â Manuel
Mar 4 at 6:12
@Manuel If you are calling it in a script then you would usevnstat -q > starttotal
at start of your script. Do your processing then usevnstat -q > endtotal
. Then parse the two output files to calculateendtotal
-starttotal
=bytesused
.
â WinEunuuchs2Unix
Mar 4 at 12:55
add a comment |Â
Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
â Manuel
Mar 4 at 6:12
@Manuel If you are calling it in a script then you would usevnstat -q > starttotal
at start of your script. Do your processing then usevnstat -q > endtotal
. Then parse the two output files to calculateendtotal
-starttotal
=bytesused
.
â WinEunuuchs2Unix
Mar 4 at 12:55
Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
â Manuel
Mar 4 at 6:12
Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
â Manuel
Mar 4 at 6:12
@Manuel If you are calling it in a script then you would use
vnstat -q > starttotal
at start of your script. Do your processing then use vnstat -q > endtotal
. Then parse the two output files to calculate endtotal
- starttotal
= bytesused
.â WinEunuuchs2Unix
Mar 4 at 12:55
@Manuel If you are calling it in a script then you would use
vnstat -q > starttotal
at start of your script. Do your processing then use vnstat -q > endtotal
. Then parse the two output files to calculate endtotal
- starttotal
= bytesused
.â WinEunuuchs2Unix
Mar 4 at 12:55
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1011678%2fmonitor-network-traffic-during-a-specific-time-in-linux%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at
/proc/net/dev
with network stats for each interface including bytes received and transmitted.â dsstorefile1
Mar 4 at 0:52