Giter Club home page Giter Club logo

netusage's Introduction

netusage

This is a tool for monitoring the process-level network traffic usage. It listens to all the TCP packets and groups the usage by process. NetHogs is another tool which does the exact same task.

This was the first week's entry for the کدکچال# challenge founded by monjar.

Usage

You could easily run this tool by running the python script under root privileges.

And the only requirement is the psutil package which helps us with getting the information about processes and can be easily installed using pip.

You could use -i <interval> argument to specify the interval of results being printed in seconds. For example this command runs the tool every 5 seconds:

sudo python3 ./main.py -i 5

The result looks something like this: Output

Apparently, fcntl library makes the program work only on Linux. (Issue #1) Since Windows doesn't give access to Ethernet layer, this program will only run on Linux. I may find a way to make it work on Windows later on.

Stuff to do

Other that ones mentioned in the code itself, these are what I have in mind for improving this tool:

  • Covering other network layer and transport layer protocols
  • Making the code object oriented (Packet class, Process class, etc)
  • Finding a better way of scheduling the print_result function which prints the result in each interval
  • Adding more command line arguments
  • Showing more information about the network and the packets

Contributions

Any form of feedback (issues, pull requests, ...) would be a huge help for me so thanks in advance! :)

References

All the main code about reading the packets are from this link. This link helped me a lot.

psutil package documentation

netusage's People

Contributors

mhezarei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

netusage's Issues

process fail if session out

hi

i use this process to monitor my ssh session
but if session out this programming will break
they can't find old pid in process use

It does not work on Windows

Hi.
In your REAMDE, you said that the code runs on Windows too, but it does not. the fcntl library only works on Linux.
If you want to make it work on Windows, you should use win32api library. Note that it works completely different from fcntl.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.