Hi,
I would like to know from which countries my nodes are mostly used. I tried to use arm for this but on high capacity relays arm eats the same cpu resources as the tor process it monitors, if the connection panel is activated. Switching to the connection panel lets arm often freeze. Is there another way to get country statistics from a node? Maybe something build in Tor?
Thanks,
Torland
I would like to know from which countries my nodes are mostly used. I tried to use arm for this but on high capacity relays arm eats the same cpu resources as the tor process it monitors
Have you tried tweaking the query rate options in your armrc?
https://gitweb.torproject.org/arm.git/blob/HEAD:/armrc.sample
Switching to the connection panel lets arm often freeze. Is there another way to get country statistics from a node? Maybe something build in Tor?
You can query the locale for an address from tor via...
https://gitweb.torproject.org/torspec.git/blob/HEAD:/control-spec.txt#l671
To simulate what arm does you could write a script that makes netstat/lsof/procstat queries, parse the results, then feed those addresses to the 'GETINFO ip-to-country/*' command. Actually, I could probably write a script for you that does this via stem (https://stem.readthedocs.org/en/latest/index.html)...
Cheers! -Damian
On Wednesday, 28. November 2012, 14:47:05 Damian Johnson wrote:
Have you tried tweaking the query rate options in your armrc?
https://gitweb.torproject.org/arm.git/blob/HEAD:/armrc.sample
No I have not yet tried this.
Switching to the connection panel lets arm often freeze. Is there another way to get country statistics from a node? Maybe something build in Tor?
You can query the locale for an address from tor via...
https://gitweb.torproject.org/torspec.git/blob/HEAD:/control-spec.txt#l671
To simulate what arm does you could write a script that makes netstat/lsof/procstat queries, parse the results, then feed those addresses to the 'GETINFO ip-to-country/*' command. Actually, I could probably write a script for you that does this via stem (https://stem.readthedocs.org/en/latest/index.html)...
Doing netstat queries means that I get 80000+ ip addresses on my server. Each of these addresses I would have to check against the list of relays to sort out connections to other relays and only do GETINFO ip-to-country to the remaining IPs. This sounds complicated and error-prone. Can't the ORCONN event be used to get a notification if a client connects?
Thanks for your help
Torland
Doing netstat queries means that I get 80000+ ip addresses on my server. Each of these addresses I would have to check against the list of relays to sort out connections to other relays and only do GETINFO ip-to-country to the remaining IPs. This sounds complicated and error-prone.
Not really. Does this do the trick?
========================================
from stem.control import Controller from stem.util import system
TOR_PID = "3470" # fill this in!
def get_tor_connections(): """ Provides the (ip address, port) tuples for tor's connections. """
results = [] netstat_output = system.call("netstat -np") established_entry = "ESTABLISHED %s/tor" % TOR_PID
for line in netstat_output: if established_entry in line: ip, port = line.split()[4].split(':') results.append((ip, port))
return results
with Controller.from_port(control_port = 9051) as controller: controller.authenticate() relay_ips = set([desc.address for desc in controller.get_network_statuses()])
for ip, port in get_tor_connections(): if ip not in relay_ips: locale = controller.get_info('ip-to-country/%s' % ip) print 'exit connection to %s' % locale
tor-relays@lists.torproject.org