Skip to content

Commit

Permalink
Merge pull request #114 from Teingi/master
Browse files Browse the repository at this point in the history
release 1.6.2
  • Loading branch information
Teingi authored Mar 18, 2024
2 parents ed5a53b + d06e1e3 commit f125f23
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
9 changes: 3 additions & 6 deletions docs/gather_perf.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

- 支持一键获取observer进程的"扁鹊图" ,ob运行态的调用关系,用"sample"代指
- 支持一键获取observer进程的"perf 火焰图", 用"flame"代指
- 支持一键获取observer进程的"pstack 火焰图", 用"pstack"代指

```
$ obdiag gather perf [-h]
Expand All @@ -24,11 +23,10 @@ Gather Perf Summary:
+----------------+-----------+----------+--------+-------------------------------------------------------------------+

```
scope 可选项: ["sample", "flame", "pstack", "all"]
scope 可选项: ["sample", "flame", "all"]
- sample:表示采集扁鹊图
- flame: 表示采集ob的Perf火焰图
- pstack: 表示采集pstack火焰图
- all: 表示扁鹊图、ob的Perf火焰图、pstack火焰图都采集,默认值
- all: 表示扁鹊图、ob的perf火焰图,默认值

## 查看结果
收集到的数据是通过perf工具进行采集的,可以通过Flame Graph中的工具对数据进行图形转化
Expand All @@ -38,11 +36,10 @@ scope 可选项: ["sample", "flame", "pstack", "all"]
1. 解压收集到的数据
解压采集到的文件,例如解压:perf_192.168.2.11_20230117140836.zip,解压之后有如下文件
```shell script
flame.viz flame.data pstack.viz sample.data sample.viz
flame.viz flame.data sample.data sample.viz
```
对应关系如下:
- flame.viz(perf 火焰图)
- pstack.viz(pstack 火焰图)
- sample.viz(扁鹊图)


Expand Down
12 changes: 0 additions & 12 deletions handler/gather/gather_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,9 @@ def __handle_from_node(self, node, local_stored_path):
self.__gather_perf_sample(ssh_helper, remote_dir_full_path, pid_observer)
elif self.scope == "flame":
self.__gather_perf_flame(ssh_helper, remote_dir_full_path, pid_observer)
elif self.scope == "pstack":
self.__gather_pstack(ssh_helper, remote_dir_full_path, pid_observer)
else:
self.__gather_perf_sample(ssh_helper, remote_dir_full_path, pid_observer)
self.__gather_perf_flame(ssh_helper, remote_dir_full_path, pid_observer)
self.__gather_pstack(ssh_helper, remote_dir_full_path, pid_observer)
self.__gather_top(ssh_helper, remote_dir_full_path, pid_observer)

zip_dir(self.is_ssh, ssh_helper, "/tmp", remote_dir_name)
Expand Down Expand Up @@ -181,15 +178,6 @@ def __gather_perf_flame(self, ssh_helper, gather_path, pid_observer):
except:
logger.error("generate perf data on server [{0}] failed".format(ssh_helper.get_name()))

def __gather_pstack(self, ssh_helper, gather_path, pid_observer):
try:
pstack_cmd = "cd {gather_path} && pstack {pid} > pstack.viz".format(
gather_path=gather_path, pid=pid_observer)
logger.info("gather pstack, run cmd = [{0}]".format(pstack_cmd))
SshClient().run(ssh_helper, pstack_cmd) if self.is_ssh else LocalClient().run(pstack_cmd)
except:
logger.error("gather pstack on server failed [{0}]".format(ssh_helper.get_name()))

def __gather_top(self, ssh_helper, gather_path, pid_observer):
try:
cmd = "cd {gather_path} && top -Hp {pid} -b -n 1 > top.txt".format(
Expand Down
14 changes: 14 additions & 0 deletions handler/gather/scenes/cpu_high.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from handler.gather.gather_obstack2 import GatherObstack2Handler
from handler.gather.gather_perf import GatherPerfHandler
from utils.parser_utils import ParserAction
from handler.gather.gather_log import GatherLogHandler

class CPUHighScene(object):
def __init__(self, nodes, cluster, report_path, task_variable_dict=None, args=None, env={}):
Expand All @@ -34,11 +35,13 @@ def __init__(self, nodes, cluster, report_path, task_variable_dict=None, args=No
self.args = args
self.env = env
self.is_ssh = True
self.ob_nodes = nodes

def execute(self):
self.__gather_obstack()
self.__gather_perf()
self.__gather_current_clocksource()
self.__gather_log()

def __gather_obstack(self):
logger.info("gather obstack start")
Expand Down Expand Up @@ -67,6 +70,17 @@ def __gather_current_clocksource(self):
except Exception as e:
logger.error("SshHandler init fail. Please check the node conf. Exception : {0} .".format(e))

def __gather_log(self):
try:
logger.info("gather observer log start")
handler = GatherLogHandler(nodes=self.ob_nodes, gather_pack_dir=self.report_path, is_scene=True)
self.args = ParserAction.add_attribute_to_namespace(self.args, 'grep', None)
handler.handle(self.args)
logger.info("gather observer log end")
except Exception as e:
logger.error("gather observer log failed, error: {0}".format(e))
raise Exception("gather observer log failed, error: {0}".format(e))

def report(self, file_path, command, data):
try:
with open(file_path, 'a', encoding='utf-8') as f:
Expand Down
2 changes: 1 addition & 1 deletion handler/gather/scenes/sql_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __gather_log(self):
try:
logger.info("gather observer log start")
handler = GatherLogHandler(nodes=self.ob_nodes, gather_pack_dir=self.report_path, is_scene=True)
self.args = ParserAction.add_attribute_to_namespace(self.args, 'grep', "")
self.args = ParserAction.add_attribute_to_namespace(self.args, 'grep', None)
handler.handle(self.args)
logger.info("gather observer log end")
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion rpm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

python_bin='python'
W_DIR=`pwd`
VERSION=${VERSION:-'1.6.1'}
VERSION=${VERSION:-'1.6.2'}


function python_version()
Expand Down
2 changes: 1 addition & 1 deletion rpm/oceanbase-diagnostic-tool.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: oceanbase-diagnostic-tool
Version:1.6.1
Version:1.6.2
Release: %(echo $RELEASE)%{?dist}
Summary: oceanbase diagnostic tool program
Group: Development/Tools
Expand Down
4 changes: 2 additions & 2 deletions utils/parser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ def parse_argv(self, argv=None):
"compress and pack, and transmit to the specified path of the obdiag machine.")
gather_perf_arguments.set_defaults(gather_sysstat=self.client.handle_gather_perf_command)
gather_perf_arguments.add_argument("--scope", metavar="scope", nargs=1,
choices=["sample", "flame", "pstack", "all"],
choices=["sample", "flame", "all"],
default="all",
help="perf type constrains, "
"choices=[sample, flame, pstack, all], "
"choices=[sample, flame, all], "
"default=all")

# gather 子命令 plan_monitor
Expand Down

0 comments on commit f125f23

Please sign in to comment.