Skip to content

Commit

Permalink
Add test mode support for loglevel command in ldmsd_controller
Browse files Browse the repository at this point in the history
  • Loading branch information
nichamon authored and tom95858 committed Oct 28, 2024
1 parent 290a9aa commit bfd5824
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions ldms/python/ldmsd/ldmsd_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': []},
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ldms/python/ldmsd/ldmsd_controller
Original file line number Diff line number Diff line change
Expand Up @@ -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}')

Expand Down

0 comments on commit bfd5824

Please sign in to comment.