Skip to content

Commit

Permalink
Merge branch 'oceanbase:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
oraclebird authored Jul 16, 2024
2 parents c57f281 + 5e8cea2 commit 6aea40d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions handler/gather/gather_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,17 @@ 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)))
raise Exception('The grep args must be string or list of strings, but got {0}'.format(type(grep_option)))
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:
Expand Down
9 changes: 5 additions & 4 deletions handler/gather/gather_obproxy_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,18 @@ 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)))
raise Exception('The grep args must be string or list of strings, but got {0}'.format(type(grep_arg)))
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:
Expand Down

0 comments on commit 6aea40d

Please sign in to comment.