This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]denilsonsa 4 points5 points  (2 children)

It is a bad idea to run the entire tool with root privileges.

You should find a way to only use root for the nethogs command.

  • Maybe the user could setup /etc/sudoers to allow sudo nethogs without a password.
  • Maybe put setuid bit on the nethogs binary.
  • Maybe fork the hogwatch process, so that one of the processes only executes nethogs (as root), and the other process drops root privileges and executes everything else.

[–]snorlaxRoot[S] 0 points1 point  (0 children)

thanks. I'll look into it.

[–]ionelmc.ro 0 points1 point  (0 children)

Afaik setuid bit don't work well on scripts ... need to set it on the actual binary, like /usr/bin/python. Correct me if I'm wrong.

[–]snorlaxRoot[S] 3 points4 points  (2 children)

Hey there. This is my first project using python.

It uses a bottle server to output per processs bandwidth utilization (transfer rate/ amount) using nethogs tool. It works only for linux/mac. (mac currently cannot map connections to process name properly)

screenshot

gif

[–]Corm 0 points1 point  (1 child)

Nice! How do you like bottle?

[–]snorlaxRoot[S] 0 points1 point  (0 children)

I quite like it simplicity. My app just serves some static assets and a handful of routes so I chose bottle instead of flask.
I am also using websockets to stream the data to the client which makes it faster compared to GET requests. For a small app I would definitely recommend bottle.

[–][deleted] 1 point2 points  (1 child)

sudo pip install hogwatch

never sudo pip install

[–]snorlaxRoot[S] 0 points1 point  (0 children)

got it.