[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-relays] Tor-Plugin for munin
> Everybody likes graphs, right?
>
> I tried some of the available munin plugins, but none of those were
> really working anymore. So I sat down and began writing my own, using
> stem, which is really awesome.
>
> These are really early stages, but it already supports autoconf
> determination and suggestions. If you want to take a look, it is
> hosted on github[1].
>
> At the moment it supports a connection graph, getting its data from
> orconn-status. More graphs are possible, but not yet implemented.
> Ideas are welcome.
Neat, thanks Martin! Added munin-tor to our examples...
https://stem.torproject.org/tutorials/double_double_toil_and_trouble.html
Few quick thoughts about the Stem bits...
> with Controller.from_port(port=port) as controller:
> controller.authenticate()
> if controller.is_authenticated():
> print('yes')
> else:
> print('no (Authentication failed)')
The is_authenticated() is unnecessary. The authenticate() call will
raise an AuthenticationFailure if unsuccessful...
https://stem.torproject.org/api/connection.html#stem.connection.authenticate
> response = controller.get_info('orconn-status')
You might want to do the following instead if you'd rather not risk
exceptions...
response = controller.get_info('orconn-status', None)
if response is None:
return
> states = {'NEW': 0, 'LAUNCHED': 0, 'CONNECTED': 0, 'FAILED': 0, 'CLOSED': 0}
Up to you but you could also use Stem's ORStatus enum.
>>> import stem
>>> dict((state, 0) for state in stem.ORStatus)
{'NEW': 0, 'CONNECTED': 0, 'CLOSED': 0, 'LAUNCHED': 0, 'FAILED': 0}
> response = controller.get_info('traffic/read')
> print('read.value {}'.format(response))
> response = controller.get_info('traffic/written')
> print('written.value {}'.format(response))
Again, this could potentially raise exceptions unless you provide
get_info() a default value.
Cheers! -Damian
_______________________________________________
tor-relays mailing list
tor-relays@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays