You are not logged in.

#1 2012-05-30 17:39:17

kaari
Member
Registered: 2011-08-12
Posts: 22

Simple command to get network usage?

I found dozens of network utilities, but none does this simple task without fancy formatting or live graphs:

Return the number of MB downloaded.

I'd like to add it to my .xinitrc so that it appears on the dwm status bar.

Offline

#2 2012-05-30 17:42:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,292

Re: Simple command to get network usage?

cat /sys/class/net/eth0/statistics/rx_bytes

Change eth0 as needed.

Edit: I do my dwmStatus bar in C just by reading from a handful of files under /sys/class/.  This is several orders of magnitude less resource intensive than bash functions using all sorts of whacky monitoring tools.

Last edited by Trilby (2012-05-30 17:44:34)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2012-05-30 18:36:24

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Simple command to get network usage?

Trilby wrote:

I do my dwmStatus bar in C

Sorry for the OT, but can you post the code / share a link?

Offline

#4 2012-05-30 19:47:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,292

Re: Simple command to get network usage?

Just put it up on github.  Please see the README before you attempt to use it.

Edit: I have a cleaner version (fewer unnecessary variables) on my work computer.  I'll update with that tomorrow.  Nonetheless, this should serve as an adequate template, and it works well - I'm still using this version on my home computer.  That version also has the battery monitor code ... this one just has an empty placeholder for it.

Last edited by Trilby (2012-05-30 20:04:51)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2021-04-18 09:14:17

DireWolf
Member
Registered: 2021-04-15
Posts: 9

Re: Simple command to get network usage?

Try vnstat its a simple cli, with optional graph outputting capabilities.
Or nethogs if you want the data to be sorted into programs...

Offline

#6 2021-04-18 12:18:53

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 3,624

Re: Simple command to get network usage?

Thanks for the contribution, but this thread is very old and the OP has not been back since 2015. Closing.

https://gitlab.archlinux.org/archlinux/ … ro-bumping

Online

Board footer

Powered by FluxBB