
What: A terminal tool to check what is taking up your bandwidth - PleaseHelpMe
https://github.com/imsnif/what
======
imsnif
Hey,

I am the author of "what" and am very happy to hear people like this tool I
made. :)

"what" was my first real attempt at rust, and I love the project very much.

That said, it is a hobby project - and so I will likely be a few days
responding to all issues and contributions that came from this thread.

"what" has already received some great contributions that are major parts of
the code base. I would be very happy for more (in the form of features, bug
fixes, issues and packaging).

A note to those having issues installing: as mentioned in this thread,
packaging for all the various linux distributions and mac is a great effort. I
apologize that at the moment the installation is a little bumpy (especially
for those not very familiar with rust).

A good first step for if "cargo install what" isn't working is to try to
`rustup update` so you get the latest version of rust and cargo.

Other than that, I hope to support your setup in the future, and/or hear from
you in the issues of the repo. Debug help for OSes I do not have access to
would be greatly appreciated. :)

Thank you all!

~~~
0xFACEFEED
What are your thoughts on Rust so far? What primary language(s) did you come
from?

I've been planning to learn Rust but haven't made the leap yet because I
expect a big time commitment due to the learning curve. I poked around your
source code and it was inspiring. Your code looks simple and straightforward
compared to some of the other Rust projects I've examined.

~~~
imsnif
That's high praise - thank you very much for saying so.

My major language in recent years has been javascript (and years before that
perl). Rust was a breath of fresh air for me as I did not previously have
"access" to system-level functionality.

I very much love the ease with which I can rely on other people's code (feels
like home coming from node.js) - even though as mentioned in this thread it
does have its downsides (eg. longer compiler times).

The learning curve is indeed challenging, but the tooling is amazing, the
compiler has better error messages than I could even have imagined, and the
community is incredibly friendly and welcoming. All in all, I'd say it's worth
the effort. :)

------
lazyjones
Bad naming..

    
    
      WHAT(1)                   BSD General Commands Manual                  WHAT(1)
      NAME
           what -- show what versions of object modules were used to construct a file
    

(MacOS ...)

~~~
anilgulecha
This is in the top class of utilities (htopm etc).

A good name could probably be bwtop, or tcptop or iftop.

Actually I searched for these, and turns out iftop exists!
([https://linux.die.net/man/8/iftop](https://linux.die.net/man/8/iftop))

~~~
rotten
My complaint about the name is that it would be hard to "google" it. This
means if I don't bookmark it or remember where I found it, then a couple of
years from now when my laptop needs to be rebuilt, I'll have the darndest time
finding it to install it again.

~~~
overcast
Every browser has book marking syncing in some capacity these days. It's the
equivalent of losing contacts with a new phone in 1999.

~~~
tjoff
Not without creating an account, on Android.

Chrome has no other export functionality. And firefox copied that lack-of-
feature without even realizing the motivations.

So now one have to copy them one by one.

~~~
lostlogin
I must be misunderstanding something here, can you please explain the missing
feature?

I load a set of bookmarks into Firefox on client machines regularly, but I
suspect this isn’t what you are discussing.

~~~
tjoff
I'm are talking firefox/chrome for android only. The only way to export
bookmarks (and possibly import) is to register for an account and sync them.

There is no way to export them to an xml/whatever file (pretty sure you could
at least in firefox before, but I guess it was too hard to maintain...).

------
imsnif
Name has changed to "bandwhich" as suggested here:
[https://old.reddit.com/r/rust/comments/ehl68y/what_a_termina...](https://old.reddit.com/r/rust/comments/ehl68y/what_a_terminal_tool_to_check_what_is_taking_up/fckesmm/)

~~~
wodenokoto
That is such a great name! I love it!

------
plmu
Installation with yay/crate can be slow. This small tool took 4 minutes of
compile time, the Rust crates seem to be very fine granular (like node.js vor
example) and require much compile time. 204 crates needed to be compiled.

I found that, using yay or another aur helper on arch linux, having a few rust
utilities installed that have regular updates, significantly slows down the
average system upgrade time. I tend to avoid Rust programs for that reason.

~~~
adimitrov
That's the nature of these spare time one (wo)man side projects: packaging a
piece of software for a wide variety of distributions and platforms is tedious
and boring, so unless there's a large community (or money) involved, you have
to compile it from source.

Of course, you can always package your favourite utility for your favourite
distribution. I'm sure the author would be thrilled to endorse your package in
the Readme.

Note also that Rust can compile to portable static binaries. This tool is
available as such from the releases page on GH (it's in the readme)

~~~
psibi
How is that musl based binary built ? I saw the repositories travis
configuration and wasn't able to find anything relevant.

~~~
steveklabnik
The simplest way is to pass the —target flag with the musl target; that should
work unless you’re also including C code, and then it may Just Work or may
need you to do something special.

~~~
res0nat0r
I've been using `nethogs` for this for a long time, and it is already in most
Linux repos and can be installed quickly.

[https://github.com/raboof/nethogs](https://github.com/raboof/nethogs)

~~~
BenjiWiebe
Not at my computer atm, but nethogs won't list the process name/PID, will it?

~~~
dima55
Yes it does. That's the whole point

------
gluegadget
A bit unrelated but I wrote
[https://github.com/amir/hepccn](https://github.com/amir/hepccn) to list TCP
connections by domains rather than just IPs. It filters connections to port
443 and 8443, downloads the peer certificate and then extracts the subject
name (pretty sure I learned this trick from an article on Julia Evans' website
but can't find it now). I wanted to add more functionalities to it but I
stumbled upon an issue and that's for when SNI is enabled. I guess there's no
way for me to recover the hostname the client has sent at the start of the
handshaking process without introducing MITM, right?

~~~
tialaramex
You won't be able to recover it after the fact, but the SNI is cleartext on
the wire as part of ClientHello even in TLS 1.3. Work to encrypt this is an
ongoing effort (called eSNI).

------
hnarn
What are the main differences to something like nethogs or iftop?

~~~
jxf
They are similar but they answer different questions.

By default, iftop will tell you "this network interface on your machine is
talking a lot to ycombinator.com". But you don't necessarily know which
processes are doing the most talking collectively.

This will tell you "Firefox process 4567 is talking a lot ycombinator.com" and
you'll know whether 4567 is also one of the chattiest talkers right now.

~~~
bicolao
> This will tell you "Firefox process 4567 is talking a lot ycombinator.com"
> and you'll know whether 4567 is also one of the chattiest talkers right now.

But that's what nethogs does.

~~~
pmontra
nethogs doesn't have the raw output mode. That could be useful. I'd take
nethogs' real time display and what's raw output.

------
pmontra
I find the --raw output more useful than the interactive one. it scrolls away
but I have time to read what's going on. The other one just disappears and is
replaced by something else, which could be ok except sometimes there are
seconds of useless black screen when nothing is going on. I suggest to never
have blank screens. A suggestion for the raw output: add a timestamp at the
beginning of the line. Probably HHMMSS is enough but YYYYmmdd would be handy
for logging in background.

~~~
noisy_boy
Seconded. It might be a good idea to have a separate "top-so-far" section that
can build-up over time to show the top consumers (and also allow sorting this
by hostname to avoid too much jumping).

------
DINKDINK
What's the difference between what and nettop?

Other similar tools:

    
    
      nettop
      iptraf
      iftop
      nethogs

~~~
TwoNineFive
I immediately thought if iftop and iptraf

[https://www.binarytides.com/linux-commands-monitor-
network/](https://www.binarytides.com/linux-commands-monitor-network/)

There's already a ton of tools that do this. It's a nice show-off project but
I doubt OP is in for the long haul.

------
cheez
Getting an error:

    
    
        .cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.3/src/bytes.rs:121:18
            |
        121 |             len: bytes.len(),
            |                  ^^^^^^^^^^^
    
        error: aborting due to previous error
    
        error: Could not compile `bytes`.
        warning: build failed, waiting for other jobs to finish...

~~~
wscott
It requires a very recent version of rust. Do a 'rustup update' to get the
latest stable release. You can't use the distribution's packages for rust and
cargo if you want to play new rust programs.

~~~
cheez
Makes sense.

------
deft
Thank you this is amazing. I have a bunch of virtual interfaces on my server
and I have no idea what's using them or if they're even still in use what
created them. This solved my problem instantly.

------
jl6
Looks awesome but the name makes it seem designed to be difficult to find in a
search engine!

------
Dowwie
top of HN front page and without mentioning that it is written in Rust

~~~
aliveupstairs
What's that have to do with anything (it being top front page)? are there
guidelines for naming posts so that the language a software is written in is
preferably in the title?

~~~
dwohnitmok
Parent is probably being a bit sarcastic and referring to the perception that
HN zeroes in and upvotes submissions based on how trendy the implementation
language is.

------
strictfp
I'll take this moment to plug the tool 'origin', which plows through aliases
and symlinks to find the executable behind a command:
[https://github.com/atorstling/origin](https://github.com/atorstling/origin)

~~~
dantillberg
What connection does 'origin' have to 'what'?

~~~
strictfp
I thought it was scratching a similar itch - simplifying a common everyday
task

------
acrossthepond10
Error: Failed to listen on network interface: No such file or directory (os
error 2)

on macOS. Anyone else getting this error?

~~~
decio
On macOS 10.14.6 the command starts but the frames stays empty (silent error)
because of SIP

"Sandbox: lsof System Policy: deny(1)"

Otherwise, really nice idea and work!

~~~
ronyfadel
I have SIP disabled, and I'm getting `Error: Failed to listen on network
interface: No such file or directory (os error 2)`

------
unnouinceput
On Windows I find TCPView from good old Sysinternals to be perfect for this
job.

------
afinlayson
Why do I need cargo to install on mac? (It would be nice to have a link to
install)

 _Updated_ To install run: curl [https://sh.rustup.rs](https://sh.rustup.rs)
-sSf | sh

~~~
afinlayson
Cargo isn't easily google-able ... I was hoping someone would link how to
install it, instead of being sassy.

I figured it out.

It can be found here: [https://doc.rust-lang.org/cargo/getting-
started/installation...](https://doc.rust-lang.org/cargo/getting-
started/installation.html)

You can install it easily by running this: curl
[https://sh.rustup.rs](https://sh.rustup.rs) -sSf | sh

~~~
aspaceman
Very first result for "cargo tool programming"

[https://binx.io/blog/2018/11/27/learning-
cargo/](https://binx.io/blog/2018/11/27/learning-cargo/)

You're getting snark because your own snarky comment is the equivalent of
saying "Why do I need Make to run it on the MacOS?" If you had asked instead,
"What is cargo, and how do I install it?" you would get more helpful
responses. Snark is met with snark.

~~~
mrtksn
And how people are supposed to know that it is a programming tool? I assumed
that it is yet another package manager and googling about cargo brings results
about logistics.

It took me a few tries before figuring it out. What worked was "Install cargo
MacOS" and it was hard to tell if the results are not a scam to make me
install some spyware.

~~~
sciurus
You assumed right, Cargo is the Rust package manager

------
MacKay
'bandwhich' I like the new name a lot!

------
ryanmjacobs
Thank god for the name change! I saw this project this morning and it looked
super interesting. I tried googling around for it to install it, but nothing
worked haha "bandwith monitor what", "github rust what", etc. And this is
coming from a hypocrite who's most popular project is named 'c'.

Bandwhich is a clever and easy to find name!

------
ExtraServings
Running Catalina, with sudo I'm able to get the screen up and running, but at
first data I get a panic:

thread 'display_handler' panicked at 'overflow when subtracting durations',
src/libcore/option.rs:1185:5 note: run with `RUST_BACKTRACE=1` environment
variable to display a backtrace.

~~~
mlindner
I'm not surprised about OS X, recent OS versions have been making it more and
more different from how the OS previously worked. For example GDB doesn't work
anymore, and neither does valgrind.

~~~
microcolonel
> _neither does valgrind_

Woah, that's a huge step backward. How do they expect anyone to write half-
decent C for their operating system without valgrind?

------
highhedgehog
Plot twist. It's the tool

~~~
C14L
Would be interesting to know how many people actually look at the source
before they compile and run random repos posted here.

~~~
zaroth
I would imagine the rate is in inverse proportion to the number of upvotes.

------
btown
Looking at how it does reverse DNS lookups to try and map backwards... is
there such thing as a crowdsourced database that resolves the most common
domain name(s) that _resulted_ in a given IP address? Seems like this would be
tremendously useful for any sort of network tooling, but I can’t find any
references from a quick search.

~~~
nimrody
You do realize that multiple domains may be hiding behind the same IP address?
This is very common with CDNs (although the bigger players can afford a static
CDN IP, I guess)

------
avoro
What can be a reason if on MacOS it does not capture traffic? I see empty
panels. Tried to run with and without `sudo`.

~~~
nsomaru
Another poster did mention that a similarly named utility already exists on
MacOS. Perhaps you’re invoking that instead?

~~~
avoro
Yes name is not unique and conflicting with existing tool. I'm launching exact
this utility by defining path as

    
    
      ~/.cargo/bin/what

or

    
    
      sudo ~/.cargo/bin/what

------
anderspitman
Very nice. I dream of the day our networking instrumentation is good enough
that when I click on a link and my browser hangs doing nothing, I can switch
to my monitor app and have it tell me exactly where the route is failing.

------
nieve
For some reason (possibly security limitations) it doesn't seem to be able to
monitor connections over a WireGuard connection's tunX interface.

~~~
imsnif
Hi!

Would you be willing to open an issue in the github repo? I am not aware of
this bug and would be very happy to address it.

I would especially be interested if this happens to be the same bug as:
[https://github.com/imsnif/bandwhich/issues/51](https://github.com/imsnif/bandwhich/issues/51)

Thanks!

------
newman8r
Will give this a spin, but anyone who enjoys this might like to take a look at
the etherape package, I really like its visualizations.

------
proverbialbunny
Is sudo required? I get

    
    
        Error: Failed to listen on network interface: Operation not permitted (os error 1)

~~~
noisy_boy
Seems that way - error went away with sudo

------
SuperSandro2000
Can I now trash iftop and nethogs?

------
ngcc_hk
Topnet might be a better name.

------
jslakro
I need this for windows.

~~~
mcyukon
I used to use Glasswire, however did not like the yearly subscription and
limited interface.

Now I use NetLimiter 4:
[https://www.netlimiter.com/](https://www.netlimiter.com/)

Among other features like process blocking, it has a process list not very
different than this utility as well has bandwidth graphing over a period in
time which is very useful in tracking down bandwidth hogs on a monthly capped
DSL line. [https://www.netlimiter.com/docs/netlimiter-
overview/features...](https://www.netlimiter.com/docs/netlimiter-
overview/features/internet-traffic-monitoring)

~~~
drummer
Netlimiter is amazing. Using it for many years. Highly recommended.

------
nutbuttercrack
Maybe you should call it iWhat? Anyway, great program!

------
makach
Is this the future? I am setting this up on my macOS, and before I could
'cargo add' anything I had to 'brew install rust'. Now it is downloading and
compiling lots and lots of dependencies.

~~~
Dowwie
you only will need to "cargo install <X>" now that you've got the rust
compiler and cargo installed on your machine

~~~
makach
Indeed. I couldn't get the tool working once it was downloaded and compiled.
iftop works fine.

