Skip to content

Commit

Permalink
Merge pull request #556 from wayyoungboy/v3.0-dev
Browse files Browse the repository at this point in the history
merge master
  • Loading branch information
wayyoungboy authored Nov 14, 2024
2 parents 4821615 + 05d684e commit 3287185
Show file tree
Hide file tree
Showing 10 changed files with 910 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
push:
branches:
- master
- v3.0-dev
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

Expand Down
2 changes: 1 addition & 1 deletion common/ssh_client/remote_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def download(self, remote_path, local_path):
transport = self._ssh_fd.get_transport()
self._sftp_client = paramiko.SFTPClient.from_transport(transport)
self.stdio.verbose('Download {0}:{1}'.format(self.host_ip, remote_path))
self._sftp_client.get(remote_path, local_path, callback=self.progress_bar)
self._sftp_client.get(remote_path, local_path)
self._sftp_client.close()

def progress_bar(self, transferred, to_be_transferred, suffix=''):
Expand Down
8 changes: 6 additions & 2 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from handler.analyzer.analyze_sql_review import AnalyzeSQLReviewHandler
from handler.analyzer.analyze_parameter import AnalyzeParameterHandler
from handler.analyzer.analyze_variable import AnalyzeVariableHandler
from handler.analyzer.analyze_memory import AnalyzeMemoryHandler
from handler.analyzer.analyze_index_space import AnalyzeIndexSpaceHandler
from handler.checker.check_handler import CheckHandler
from handler.checker.check_list import CheckListHandler
Expand Down Expand Up @@ -444,6 +445,10 @@ def analyze_fuction(self, function_type, opt):
self.set_context(function_type, 'analyze', config)
handler = AnalyzeIndexSpaceHandler(self.context)
return handler.handle()
elif function_type == 'analyze_memory':
self.set_context(function_type, 'analyze', config)
handler = AnalyzeMemoryHandler(self.context)
return handler.handle()
else:
self._call_stdio('error', 'Not support analyze function: {0}'.format(function_type))
return ObdiagResult(ObdiagResult.INPUT_ERROR_CODE, error_data='Not support analyze function: {0}'.format(function_type))
Expand Down Expand Up @@ -503,8 +508,7 @@ def rca_run(self, opts):
self.set_context('rca_run', 'rca_run', config)
try:
handler = RCAHandler(self.context)
handler.handle()
return handler.execute()
return handler.handle()
except Exception as e:
self.stdio.error("rca run Exception: {0}".format(e))
self.stdio.verbose(traceback.format_exc())
Expand Down
29 changes: 29 additions & 0 deletions diag_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,34 @@ def __init__(self):
self.register_command(ObdiagAnalyzeVariableDiffCommand())


class ObdiagAnalyzeMemoryCommand(ObdiagOriginCommand):

def __init__(self):
super(ObdiagAnalyzeMemoryCommand, self).__init__('memory', 'Analyze OceanBase Memory info from online observer machines or offline OceanBase log files')
self.parser.add_option('--from', type='string', help="specify the start of the time range. format: 'yyyy-mm-dd hh:mm:ss'")
self.parser.add_option('--to', type='string', help="specify the end of the time range. format: 'yyyy-mm-dd hh:mm:ss'")
self.parser.add_option('--grep', action="append", type='string', help="specify keywords constrain")
self.parser.add_option('--files', action="append", type='string', help="specify files")
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
self.parser.add_option('--since', type='string', help="Specify time range that from 'n' [d]ays, 'n' [h]ours or 'n' [m]inutes. before to now. format: <n> <m|h|d>. example: 1h.", default='30m')
self.parser.add_option('--temp_dir', type='string', help='the dir for temporarily storing files on nodes', default='/tmp')
self.parser.add_option('-c', type='string', help='obdiag custom config', default=os.path.expanduser('~/.obdiag/config.yml'))
self.parser.add_option('--config', action="append", type="string", help='config options Format: --config key=value')
self.parser.add_option('--version', type="string", help='specify the OceanBase version of the log file to be analyzed.This option is only used for offline analysis.')

def init(self, cmd, args):
super(ObdiagAnalyzeMemoryCommand, self).init(cmd, args)
self.parser.set_usage('%s [options]' % self.prev_cmd)
return self

def _do_command(self, obdiag):
offline_args_sign = '--files'
if self.args and (offline_args_sign in self.args):
return obdiag.analyze_fuction('analyze_memory', self.opts)
else:
return obdiag.analyze_fuction('analyze_memory', self.opts)


class ObdiagAnalyzeIndexSpaceCommand(ObdiagOriginCommand):
def __init__(self):
super(ObdiagAnalyzeIndexSpaceCommand, self).__init__('index_space', 'Analyze the space of existing or non-existent index and estimate it through the columns included in the index')
Expand Down Expand Up @@ -1210,6 +1238,7 @@ def __init__(self):
self.register_command(ObdiagAnalyzeVariableCommand())
self.register_command(ObdiagAnalyzeQueueCommand())
self.register_command(ObdiagAnalyzeIndexSpaceCommand())
self.register_command(ObdiagAnalyzeMemoryCommand())
# self.register_command(ObdiagAnalyzeSQLCommand())
# self.register_command(ObdiagAnalyzeSQLReviewCommand())

Expand Down
Loading

0 comments on commit 3287185

Please sign in to comment.