Skip to content

Commit 34d930b

Browse files
authored
[NEW] obdiag gather core (#1017)
* release 3.2.0 * release 3.4.0 * Upgrade the version to 3.5.0 * Update README-CN.md * [NEW] obdiag gather core
1 parent eeaf4cc commit 34d930b

4 files changed

Lines changed: 459 additions & 1 deletion

File tree

rpm/init_obdiag_cmd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _obdiag_completion() {
1515
;;
1616
gather)
1717
if [ "$COMP_CWORD" -eq 2 ]; then
18-
type_list="log clog slog plan_monitor stack perf sysstat obproxy_log all scene ash tabledump parameter variable dbms_xplan"
18+
type_list="log clog slog plan_monitor stack perf sysstat obproxy_log all scene ash tabledump parameter variable dbms_xplan core"
1919
elif [ "${COMP_WORDS[2]}" = "scene" ] && [ "$COMP_CWORD" -eq 3 ]; then
2020
type_list="list run"
2121
fi

src/common/core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from src.handler.gather.gather_parameters import GatherParametersHandler
5454
from src.handler.gather.gather_variables import GatherVariablesHandler
5555
from src.handler.gather.gather_dbms_xplan import GatherDBMSXPLANHandler
56+
from src.handler.gather.gather_core import GatherCoreHandler
5657
from src.handler.display.display_scenes import DisplaySceneHandler
5758
from src.handler.display.scenes.list import DisplayScenesListHandler
5859
from src.handler.update.update import UpdateHandler
@@ -362,6 +363,9 @@ def gather_function(self, function_type, opt):
362363
elif function_type == 'gather_dbms_xplan':
363364
handler = GatherDBMSXPLANHandler(self.context)
364365
return handler.handle()
366+
elif function_type == 'gather_core':
367+
handler = GatherCoreHandler(self.context)
368+
return handler.handle()
365369
else:
366370
self._call_stdio('error', 'Not support gather function: {0}'.format(function_type))
367371
return ObdiagResult(ObdiagResult.INPUT_ERROR_CODE, error_data='Not support gather function: {0}'.format(function_type))

src/common/diag_cmd.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,25 @@ def _do_command(self, obdiag):
774774
return obdiag.gather_function('gather_dbms_xplan', self.opts)
775775

776776

777+
class ObdiagGatherCoreCommand(ObdiagOriginCommand):
778+
def __init__(self):
779+
super(ObdiagGatherCoreCommand, self).__init__('core', 'Gather core diagnostic information')
780+
self.parser.add_option('--from', type='string', help="specify the start of the time range. format: 'yyyy-mm-dd hh:mm:ss'")
781+
self.parser.add_option('--to', type='string', help="specify the end of the time range. format: 'yyyy-mm-dd hh:mm:ss'")
782+
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')
783+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
784+
self.parser.add_option('-c', type='string', help='obdiag custom config', default=os.path.expanduser('~/.obdiag/config.yml'))
785+
self.parser.add_option('--config', action="append", type="string", help='config options Format: --config key=value')
786+
787+
def init(self, cmd, args):
788+
super(ObdiagGatherCoreCommand, self).init(cmd, args)
789+
self.parser.set_usage('%s [options]' % self.prev_cmd)
790+
return self
791+
792+
def _do_command(self, obdiag):
793+
return obdiag.gather_function('gather_core', self.opts)
794+
795+
777796
class ObdiagDisplaySceneListCommand(ObdiagOriginCommand):
778797

779798
def __init__(self):
@@ -1227,6 +1246,7 @@ def __init__(self):
12271246
self.register_command(ObdiagGatherParameterCommand())
12281247
self.register_command(ObdiagGatherVariableCommand())
12291248
self.register_command(ObdiagGatherDBMSXPLANHandler())
1249+
self.register_command(ObdiagGatherCoreCommand())
12301250

12311251

12321252
class ObdiagDisplayCommand(MajorCommand):

0 commit comments

Comments
 (0)