expires_after cardinality, bug fixes

This commit is contained in:
Arseniy Kuznetsov
2022-09-17 09:43:46 +01:00
parent 7aeb02ac71
commit d0456eab19
10 changed files with 45 additions and 25 deletions

View File

@@ -21,3 +21,5 @@
bandwidth = True # Turns metrics bandwidth metrics collection on / off
bandwidth_test_interval = 420 # Interval for colllecting bandwidth metrics
verbose_mode = False # Set it on for troubleshooting

View File

@@ -58,6 +58,7 @@ class MKTXPConfigKeys:
MKTXP_INC_DIV = 'delay_inc_div'
MKTXP_BANDWIDTH_KEY = 'bandwidth'
MKTXP_BANDWIDTH_TEST_INTERVAL = 'bandwidth_test_interval'
MKTXP_VERBOSE_MODE = 'verbose_mode'
# UnRegistered entries placeholder
NO_ENTRIES_REGISTERED = 'NoEntriesRegistered'
@@ -86,7 +87,8 @@ class MKTXPConfigKeys:
FE_MONITOR_KEY, FE_ROUTE_KEY, MKTXP_USE_COMMENTS_OVER_NAMES,
FE_WIRELESS_KEY, FE_WIRELESS_CLIENTS_KEY, FE_CAPSMAN_KEY, FE_CAPSMAN_CLIENTS_KEY, FE_POE_KEY, FE_NETWATCH_KEY}
SYSTEM_BOOLEAN_KEYS_YES = (MKTXP_BANDWIDTH_KEY,)
SYSTEM_BOOLEAN_KEYS_YES = {MKTXP_BANDWIDTH_KEY}
SYSTEM_BOOLEAN_KEYS_NO = {MKTXP_VERBOSE_MODE}
STR_KEYS = (HOST_KEY, USER_KEY, PASSWD_KEY)
MKTXP_INT_KEYS = (PORT_KEY, MKTXP_SOCKET_TIMEOUT, MKTXP_INITIAL_DELAY, MKTXP_MAX_DELAY, MKTXP_INC_DIV, MKTXP_BANDWIDTH_TEST_INTERVAL)
@@ -106,14 +108,15 @@ class ConfigEntry:
])
MKTXPSystemEntry = namedtuple('MKTXPSystemEntry', [MKTXPConfigKeys.PORT_KEY, MKTXPConfigKeys.MKTXP_SOCKET_TIMEOUT,
MKTXPConfigKeys.MKTXP_INITIAL_DELAY, MKTXPConfigKeys.MKTXP_MAX_DELAY,
MKTXPConfigKeys.MKTXP_INC_DIV, MKTXPConfigKeys.MKTXP_BANDWIDTH_KEY, MKTXPConfigKeys.MKTXP_BANDWIDTH_TEST_INTERVAL])
MKTXPConfigKeys.MKTXP_INC_DIV, MKTXPConfigKeys.MKTXP_BANDWIDTH_KEY,
MKTXPConfigKeys.MKTXP_VERBOSE_MODE, MKTXPConfigKeys.MKTXP_BANDWIDTH_TEST_INTERVAL])
class OSConfig(metaclass = ABCMeta):
''' OS-related config
'''
@staticmethod
def os_config(quiet = False):
def os_config():
''' Factory method
'''
if sys.platform == 'linux':
@@ -121,8 +124,7 @@ class OSConfig(metaclass = ABCMeta):
elif sys.platform == 'darwin':
return OSXConfig()
else:
if not quiet:
print(f'Non-supported platform: {sys.platform}')
print(f'Non-supported platform: {sys.platform}')
return None
@property
@@ -244,11 +246,11 @@ class MKTXPConfigHandler:
system_entry_reader[key] = self._default_value_for_key(key)
write_needed = True # read from disk next time
for key in MKTXPConfigKeys.SYSTEM_BOOLEAN_KEYS_YES:
for key in MKTXPConfigKeys.SYSTEM_BOOLEAN_KEYS_NO.union(MKTXPConfigKeys.SYSTEM_BOOLEAN_KEYS_YES):
if self._config[entry_name].get(key):
system_entry_reader[key] = self._config[entry_name].as_bool(key)
else:
system_entry_reader[key] = True
system_entry_reader[key] = True if key in MKTXPConfigKeys.SYSTEM_BOOLEAN_KEYS_YES else False
write_needed = True # read from disk next time
if write_needed:

View File

@@ -89,18 +89,17 @@ class MKTXPDispatcher:
ExportProcessor.start()
def print(self, args):
if not (args['wifi_clients'] or args['capsman_clients']):
print("Select metric option(s) to print out, or run 'mktxp print -h' to find out more")
if args['wifi_clients']:
OutputProcessor.wifi_clients(args['entry_name'])
if args['capsman_clients']:
elif args['capsman_clients']:
OutputProcessor.capsman_clients(args['entry_name'])
if args['dhcp_clients']:
elif args['dhcp_clients']:
OutputProcessor.dhcp_clients(args['entry_name'])
else:
print("Select metric option(s) to print out, or run 'mktxp print -h' to find out more")
def main():
MKTXPDispatcher().dispatch()

View File

@@ -218,8 +218,9 @@ Selected metrics info can be printed on the command line. For more information,
return editor
commands = ['which nano', 'which vi', 'which vim']
quiet = not config_handler.system_entry().verbose_mode
for command in commands:
editor = run_cmd(command, quiet = True).rstrip()
editor = run_cmd(command, quiet = quiet).rstrip()
if editor:
break
return editor