How to see how much data (in Mo for download/upload) was sent through my Tor usage? I know that tor.exe in windows says how much data was sent if the connection is re-established, but does it store it somewhere? And I don't know how to look up this in Linux (which I'm using right now).
This is already a built in feature in the anonymizing relay monitor (Arm) which provides real time statistics for:
- bandwidth (upload/download), cpu and memory usage
- relay's current configuration
- logged events connection details (ip, hostname, fingerprint, and consensus data)
- ...etc
(Picture above for the case of a relay, but it also works for a client)
It can be achieved via stem-using script. Tor itself makes some runtime data, but does not have a built-in extensive statistics module. You can regulary poll a Tor instance and collect data from running Tor instance and summarize it yourself
The control port provides two bits of information traffic/read
and traffic/written
which can be queried by the GETINFO
command.
This will provide the traffic read and written by the Tor daemon since it was last launched.
The stem
library provides a simple interface to the control port illustrated in this example code to fetch these two values, from this tutorial:
from stem.control import Controller
with Controller.from_port(port = 9051) as controller:
controller.authenticate() # provide the password here if you set one
bytes_read = controller.get_info("traffic/read")
bytes_written = controller.get_info("traffic/written")
print("My Tor relay has read %s bytes and written %s." % (bytes_read, bytes_written))
While it explicitly states relay, which is it's example use case, this also applies to clients. The above script assumes that Tor is running a control port on 9051/tcp on localhost.