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

Plugin tor_: handle missing dependency during "fetch" or "config"

This commit is contained in:
Lars Kruse 2021-02-05 00:05:59 +01:00
parent f06ee36a05
commit 179f04721a

View file

@ -81,10 +81,11 @@ try:
import stem import stem
import stem.control import stem.control
import stem.connection import stem.connection
except ImportError: missing_dependency_error = None
except ImportError as exc:
# missing dependencies are reported via "autoconf" # missing dependencies are reported via "autoconf"
# thus failure is acceptable here # thus failure is acceptable here
pass missing_dependency_error = str(exc)
default_torcachefile = 'munin_tor_country_stats.json' default_torcachefile = 'munin_tor_country_stats.json'
default_torconnectmethod = 'port' default_torconnectmethod = 'port'
@ -517,6 +518,10 @@ def main():
TorPlugin.suggest() TorPlugin.suggest()
sys.exit() sys.exit()
else: else:
if missing_dependency_error is not None:
print("Failed to run tor_ due to missing dependency: {}"
.format(missing_dependency_error), file=sys.stderr)
sys.exit(1)
# detect data provider # detect data provider
if __file__.endswith('_bandwidth'): if __file__.endswith('_bandwidth'):
provider = TorBandwidth() provider = TorBandwidth()