diff --git a/handler/gather/gather_log.py b/handler/gather/gather_log.py index f368cab5..6001296a 100644 --- a/handler/gather/gather_log.py +++ b/handler/gather/gather_log.py @@ -304,7 +304,6 @@ def __pharse_log(self, ssh_client, home_path, log_name, gather_path): if type(self.grep_options) == str: grep_cmd = "grep -e '{grep_options}' {log_dir}/{log_name} >> {gather_path}/{log_name} ".format(grep_options=self.grep_options, gather_path=gather_path, log_name=log_name, log_dir=log_path) elif type(self.grep_options) == list and len(self.grep_options) > 0: - grep_litter_cmd = "" for grep_option in self.grep_options: if type(grep_option) != str: self.stdio.error('The grep args must be string or list of strings, but got {0}'.format(type(grep_option))) @@ -312,8 +311,10 @@ def __pharse_log(self, ssh_client, home_path, log_name, gather_path): elif grep_option == "": self.stdio.warn('The grep args must be string or list of strings, but got ""') continue - grep_litter_cmd += "| grep -e '{0}'".format(grep_option) - grep_cmd = "cat {log_dir}/{log_name} {grep_options} >> {gather_path}/{log_name} ".format(grep_options=grep_litter_cmd, gather_path=gather_path, log_name=log_name, log_dir=log_path) + if grep_cmd == "": + grep_cmd = "grep -e '{0}' ".format(grep_option) + "{log_dir}/{log_name}".format(log_name=log_name, log_dir=log_path) + grep_cmd += "| grep -e '{0}'".format(grep_option) + grep_cmd += " >> {gather_path}/{log_name} ".format(gather_path=gather_path, log_name=log_name, log_dir=log_path) self.stdio.verbose('grep files, run cmd = [{0}]'.format(grep_cmd)) ssh_client.exec_cmd(grep_cmd) else: diff --git a/handler/gather/gather_obproxy_log.py b/handler/gather/gather_obproxy_log.py index efd54b37..9f7b60fd 100644 --- a/handler/gather/gather_obproxy_log.py +++ b/handler/gather/gather_obproxy_log.py @@ -263,7 +263,6 @@ def __pharse_log(self, ssh_client, home_path, log_name, gather_path): if type(self.grep_args) == str: grep_cmd = "grep -e '{grep_args}' {log_dir}/{log_name} >> {gather_path}/{log_name} ".format(grep_args=self.grep_args, gather_path=gather_path, log_name=log_name, log_dir=log_path) elif type(self.grep_args) == list and len(self.grep_args) > 0: - grep_litter_cmd = "" for grep_arg in self.grep_args: if type(grep_arg) != str: self.stdio.error('The grep args must be string or list of strings, but got {0}'.format(type(grep_arg))) @@ -271,9 +270,11 @@ def __pharse_log(self, ssh_client, home_path, log_name, gather_path): elif grep_arg == "": self.stdio.warn('The grep args must be string or list of strings, but got ""') continue - grep_litter_cmd += "| grep -e '{0}'".format(grep_arg) - - grep_cmd = "cat {log_dir}/{log_name} {grep_args} >> {gather_path}/{log_name} ".format(grep_args=grep_litter_cmd, gather_path=gather_path, log_name=log_name, log_dir=log_path) + if grep_cmd == "": + grep_cmd = "grep -e '{0}' ".format(grep_arg) + "{log_dir}/{log_name}".format(log_name=log_name, log_dir=log_path) + continue + grep_cmd += "| grep -e '{0}'".format(grep_arg) + grep_cmd += " >> {log_dir}/{log_name}".format(log_name=log_name, log_dir=log_path) self.stdio.verbose("grep files, run cmd = [{0}]".format(grep_cmd)) ssh_client.exec_cmd(grep_cmd) else: diff --git a/handler/rca/rca_handler.py b/handler/rca/rca_handler.py index 51da1a95..993bd173 100644 --- a/handler/rca/rca_handler.py +++ b/handler/rca/rca_handler.py @@ -99,12 +99,7 @@ def __init__(self, context): obproxy_version = "" try: if len(context_obproxy_nodes) > 0: - obproxy_version = get_obproxy_version( - True, - context_obproxy_nodes[0]["ssher"], - context_obproxy_nodes[0]["home_path"], - self.stdio, - ) + obproxy_version = get_obproxy_version(context) except Exception as e: self.stdio.warn("RCAHandler.init Failed to get obproxy version. Error:{0}".format(e)) if obproxy_version != "":