From 682917ec361260f6d0813de40e3f5c88440541cd Mon Sep 17 00:00:00 2001 From: Sandro Date: Tue, 7 Jun 2022 23:11:53 +0200 Subject: [PATCH] Simplify autoconf method It's quite bogus, since any exceptions will be thrown during initialization. --- plugins/network/nft_counters | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/network/nft_counters b/plugins/network/nft_counters index c7ad9533..6a593981 100755 --- a/plugins/network/nft_counters +++ b/plugins/network/nft_counters @@ -262,21 +262,24 @@ class MuninNftCountersPlugin(MuninPlugin): def autoconf(self): + """ + Implements Munin Plugin Auto-Configuration Option. + + Returns + ------- + bool + True if plugin can be auto-configured. """ - Checks if nft command can be run (needs root) and if so, - if there any counters present in nftables - - """ - + # Any exceptions (e.g. insufficient permissions, missing dependencies) + # will already throw an exception when the plugin is initialized since + # the plugin reads all its data from nftables. So below should always + # return True (print "yes"). try: counters = getCounters() - if len(counters) > 0: - return True - else: - return False - except: + return True + except ValueError: return False