mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
parent
069255eee2
commit
04ded0c6f5
1 changed files with 8 additions and 13 deletions
|
@ -158,29 +158,24 @@ class TorPlugin(object):
|
|||
print('{}.{} {}'.format(label, key, val))
|
||||
|
||||
@staticmethod
|
||||
def autoconf():
|
||||
def get_autoconf_status():
|
||||
try:
|
||||
import stem
|
||||
|
||||
except ImportError as e:
|
||||
print('no (failed to import the required python module "stem": {})'.format(e))
|
||||
|
||||
return 'no (failed to import the required python module "stem": {})'.format(e)
|
||||
try:
|
||||
import GeoIP # noqa: F401
|
||||
|
||||
except ImportError as e:
|
||||
print('no (failed to import the required python module "GeoIP": {})'.format(e))
|
||||
|
||||
return 'no (failed to import the required python module "GeoIP": {})'.format(e)
|
||||
try:
|
||||
with gen_controller() as controller:
|
||||
try:
|
||||
authenticate(controller)
|
||||
print('yes')
|
||||
return 'yes'
|
||||
except stem.connection.AuthenticationFailure as e:
|
||||
print('no (Authentication failed: {})'.format(e))
|
||||
|
||||
except stem.connection:
|
||||
print('no (Connection failed)')
|
||||
return 'no (Authentication failed: {})'.format(e)
|
||||
except stem.SocketError:
|
||||
return 'no (Connection failed)'
|
||||
|
||||
@staticmethod
|
||||
def suggest():
|
||||
|
@ -516,7 +511,7 @@ def main():
|
|||
param = 'fetch'
|
||||
|
||||
if param == 'autoconf':
|
||||
TorPlugin.autoconf()
|
||||
print(TorPlugin.get_autoconf_status())
|
||||
sys.exit()
|
||||
elif param == 'suggest':
|
||||
TorPlugin.suggest()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue