1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +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))
@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()