
一部のWebページを解析し、セレンを使用してJavaScriptを介してページを掻き出すPythonスクリプトがありますが、累積帯域幅のurllibs
使用量を知りたいです。 nethogsを見てみましたが、1秒あたりの使用量は教えていますが、スクリプトがeth0からどのくらいのデータを受け取るか送信するかはわかりません。
理想的には、監視を開始した後にすべての新しいプロセスを追跡し、各プロセスで使用されているテーブル全体を維持したいと思います。
そのようなツールがありますか?そうでなければ、それを追跡するためにスクリプトで実装できるPythonライブラリはありますか?
答え1
外部プロセスとして実行され、接続ごとに送信されたバイト数に関する統計を提供できるネットワークモニタを探している場合IPトラフィックこれは可能です。
答え2
nethogsは累積帯域幅使用量を表示できるようになりました。 「m」を押すだけです。
usage: nethogs [-V] [-h] [-b] [-d seconds] [-v mode] [-c count] [-t] [-p] [-s] [-a] [-l] [-f filter][device [device [device ...]]]
-V : prints version.
-h : prints this help.
-b : bughunt mode - implies tracemode.
-d : delay for update refresh rate in seconds. default is 1.
-v : view mode (0 = KB/s, 1 = total KB, 2 = total B, 3 = total MB). default is 0.
-c : number of updates. default is 0 (unlimited).
-t : tracemode.
-p : sniff in promiscious mode (not recommended).
-s : sort output by sent column.
-l : display command line.
-a : monitor all devices, even loopback/stopped ones.
-f : EXPERIMENTAL: specify string pcap filter (like tcpdump). This may be removed orchanged in a future version.
device : device(s) to monitor. default is all interfaces up and running excluding loopback
When nethogs is running, press:
q: quit
s: sort by SENT traffic
r: sort by RECEIVE traffic
l: display command line
m: switch between total (KB, B, MB) and KB/s mode