1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 14:16:00 +00:00

Plugin tor_: fix autoconf issues

Closes: #1166
This commit is contained in:
Lars Kruse 2021-01-26 15:39:28 +01:00
parent 069255eee2
commit 04ded0c6f5

View file

@ -158,29 +158,24 @@ class TorPlugin(object):
print('{}.{} {}'.format(label, key, val)) print('{}.{} {}'.format(label, key, val))
@staticmethod @staticmethod
def autoconf(): def get_autoconf_status():
try: try:
import stem import stem
except ImportError as e: 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: try:
import GeoIP # noqa: F401 import GeoIP # noqa: F401
except ImportError as e: 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: try:
with gen_controller() as controller: with gen_controller() as controller:
try: try:
authenticate(controller) authenticate(controller)
print('yes') return 'yes'
except stem.connection.AuthenticationFailure as e: except stem.connection.AuthenticationFailure as e:
print('no (Authentication failed: {})'.format(e)) return 'no (Authentication failed: {})'.format(e)
except stem.SocketError:
except stem.connection: return 'no (Connection failed)'
print('no (Connection failed)')
@staticmethod @staticmethod
def suggest(): def suggest():
@ -516,7 +511,7 @@ def main():
param = 'fetch' param = 'fetch'
if param == 'autoconf': if param == 'autoconf':
TorPlugin.autoconf() print(TorPlugin.get_autoconf_status())
sys.exit() sys.exit()
elif param == 'suggest': elif param == 'suggest':
TorPlugin.suggest() TorPlugin.suggest()