1from stem.control import Controller
2
3with Controller.from_port(port = 9051) as controller:
4  controller.authenticate()  # provide the password here if you set one
5
6  bytes_read = controller.get_info("traffic/read")
7  bytes_written = controller.get_info("traffic/written")
8
9  print("My Tor relay has read %s bytes and written %s." % (bytes_read, bytes_written))
10