Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Network Process Monitor

Network Process Monitor makes it easy for Python developers to monitor a proccess’ network usage.

Currently, it works with IPv4 and tested against Python 2.7.

Development site.

© Network Process Monitor contributors 2019 under the The GNU General Public License v3.0.

Installation

Install using pip with:

pip install netprocmon

Or, download a wheel or source archive from PyPI.

Basic

>>> import time
>>> from netprocmon import Monitor
>>> pid = 586
>>> with Monitor() as a:
...      a.add_pid(pid)
...      a.start()
...      while True:
...          time.sleep(5)
...          print [str(n) for n in a.get_count_by_pid(pid)]
...
['NetworkTraffic(interface=eth1, recv=2302, pid=586, send=6806)']
['NetworkTraffic(interface=eth1, recv=2832, pid=586, send=9104)']
['NetworkTraffic(interface=eth1, recv=3548, pid=586, send=10742)', 'NetworkTraffic(interface=eth2, recv=0, pid=586, send=121)']

Listen address/interface

Limit listening to an interface by providing the interface address

>>> import time
>>> from netprocmon import Monitor
>>> pid = 586
>>> with Monitor() as a:
...      a.add_pid(pid)
...      a.add_address("10.0.0.21")
...      a.start()
...      while True:
...          time.sleep(5)
...          print [str(n) for n in a.get_count_by_pid(pid)]
...
['NetworkTraffic(interface=eth1, recv=530, pid=586, send=2758)']
['NetworkTraffic(interface=eth1, recv=1538, pid=586, send=5044)']
['NetworkTraffic(interface=eth1, recv=2386, pid=586, send=8166)']

Available constants and methods

Constants

  • P_TCP: Define the TCP protocol number

  • P_UDP: Define the UDP protocol number

Process Identification

  • add_pid(PID): Add a process identification to have the traffic counted

  • remove_pid(PID): Remove a process identification and the traffic count

  • get_pids(): Get a list of process identifications that get the traffic counted

  • get_pid_by_port(proto, port): Get the process identification based on a supervise port

  • clear_pids(): Remove all process identifications

Listening

  • add_address(addr): Add a listening restriction; The address should fit with an interface address

  • get_addresses(): Return a list of listening restrictions

  • remove_address(addr): Remove a listening restriction

  • clear_addresses(): Remove all listening restriction

  • get_listen_addrs(): Return a list of interface addresses that are being listed to

  • get_listen_interfaces(): Return a list of interfaces with their addresses that are being listed to

  • get_listen_interface_by_addr(addr): Return the interface name based on a address; If the address is not listened to, None will be returned

Run

  • start(): Start the monitor

Traffic Info

  • get_count_by_pid(PID): Get network traffic based on a process identification

Port Info

  • get_ports_by_pid(PID): Get a list of supervise ports based on a process identification

  • get_ports_by_proto(proto): Get a list of supervise ports based on TCP or UDP protocol; See P_TCP, P_UDP

  • get_ports(): Get a list of all supervise ports

Metadata

Release files for netprocmon 0.0.1rc7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netprocmon 0.0.1rc7
File Size Uploaded Provenance Actions
netprocmon-0.0.1rc7.tar.gz 17.9 kB Without provenance Details for netprocmon-0.0.1rc7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netprocmon 0.0.1rc7
File Interpreter ABI Platform Actions
netprocmon-0.0.1rc7-py2-none-any.whl Python 2 none any Details for netprocmon-0.0.1rc7-py2-none-any.whl

Total release size: 37.0 kB

Release files / netprocmon-0.0.1rc7.tar.gz

Download URL netprocmon-0.0.1rc7.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f32535daa899f9be13754616c8477ed19036d814fe5fd7971f06cbac83e20b12
BLAKE2b-256 checksum
How to use checksums
162ce9a342f4d98df729fc84d12507c4a37580b82204713e8b90da8f8f47d021
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/2.7.15

Release files / netprocmon-0.0.1rc7-py2-none-any.whl

Download URL netprocmon-0.0.1rc7-py2-none-any.whl
Size 19.1 kB
Tags Python 2
SHA-256 checksum
How to use checksums
1a0b5f736e964b712d3b7100ba8ea54e4fedfce29dfbdfa20b6aa5473ce5cb2c
BLAKE2b-256 checksum
How to use checksums
c33949af1e4ec155b84dd7ecf004b8d594c305f6c0b2ab2ceb4261f7e3dcb582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/2.7.15

Security for netprocmon 0.0.1rc7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page