From b8b727028f6a3c46d324cb662661d0618a0ae1b3 Mon Sep 17 00:00:00 2001 From: Nichamon Naksinehaboon Date: Fri, 25 Oct 2024 13:27:51 -0500 Subject: [PATCH] Add test mode support for loglevel command in ldmsd_controller --- ldms/python/ldmsd/ldmsd_communicator.py | 11 ++++++++--- ldms/python/ldmsd/ldmsd_controller | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ldms/python/ldmsd/ldmsd_communicator.py b/ldms/python/ldmsd/ldmsd_communicator.py index 0ae352f83..cc39155a7 100644 --- a/ldms/python/ldmsd/ldmsd_communicator.py +++ b/ldms/python/ldmsd/ldmsd_communicator.py @@ -76,7 +76,7 @@ 'udata_regex': {'req_attr': ['instance', 'regex', 'base'], 'opt_attr': ['incr']}, 'version': {'req_attr': [], 'opt_attr': []}, - 'loglevel': {'req_attr': ['level'],}, + 'loglevel': {'req_attr': ['level'], 'opt_attr' : ['test']}, 'include': {'req_attr': ['path'] }, 'env': {'req_attr': []}, 'logrotate': {'req_attr': [], 'opt_attr': []}, @@ -1722,7 +1722,7 @@ def update_time_stats(self, name=None): self.close() return errno.ENOTCONN, str(e) - def loglevel(self, level): + def loglevel(self, level, is_test = False): """ Change the verbosity level of ldmsd @@ -1733,8 +1733,13 @@ def loglevel(self, level): - status is an errno from the errno module - data is an error message if status !=0 or None """ + if is_test: + __test = "true" + else: + __test = "false" req = LDMSD_Request(command_id=LDMSD_Request.VERBOSITY_CHANGE, - attrs=[LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.LEVEL, value=level)]) + attrs=[LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.LEVEL, value=level), + LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.TEST, value=__test)]) try: req.send(self) resp = req.receive(self) diff --git a/ldms/python/ldmsd/ldmsd_controller b/ldms/python/ldmsd/ldmsd_controller index 35fffd286..4cca49886 100755 --- a/ldms/python/ldmsd/ldmsd_controller +++ b/ldms/python/ldmsd/ldmsd_controller @@ -1367,7 +1367,7 @@ class LdmsdCmdParser(cmd.Cmd): """ arg = self.handle_args('loglevel', arg) if arg: - rc, msg = self.comm.loglevel(arg['level']) + rc, msg = self.comm.loglevel(arg['level'], arg['test']) if rc: print(f'Error changing log level to arg["level"]: {msg}')