Skip to content

Commit f1a20e3

Browse files
authored
Add a check to verify if perf is installed on the system when gather perf (oceanbase#633)
* Rename Dockerfile to DockerFile * fix * fix * fixed: issue oceanbase#620 * fixed: issue oceanbase#620 * fixed: issue oceanbase#620
1 parent b67cfbb commit f1a20e3

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

dev_helper.sh

100644100755
File mode changed.

src/handler/gather/gather_perf.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,14 @@ def __handle_from_node(self, node, local_stored_path):
142142
resp["error"] = "can't find observer"
143143
return resp
144144
for pid_observer in pid_observer_list:
145-
if self.scope == "sample":
146-
self.__gather_perf_sample(ssh_client, remote_dir_full_path, pid_observer)
147-
elif self.scope == "flame":
148-
self.__gather_perf_flame(ssh_client, remote_dir_full_path, pid_observer)
149-
else:
150-
self.__gather_perf_sample(ssh_client, remote_dir_full_path, pid_observer)
151-
self.__gather_perf_flame(ssh_client, remote_dir_full_path, pid_observer)
145+
if self.__perf_checker(ssh_client):
146+
if self.scope == "sample":
147+
self.__gather_perf_sample(ssh_client, remote_dir_full_path, pid_observer)
148+
elif self.scope == "flame":
149+
self.__gather_perf_flame(ssh_client, remote_dir_full_path, pid_observer)
150+
else:
151+
self.__gather_perf_sample(ssh_client, remote_dir_full_path, pid_observer)
152+
self.__gather_perf_flame(ssh_client, remote_dir_full_path, pid_observer)
152153
self.__gather_top(ssh_client, remote_dir_full_path, pid_observer)
153154

154155
zip_dir(ssh_client, "/tmp", remote_dir_name, self.stdio)
@@ -177,6 +178,17 @@ def __gather_perf_sample(self, ssh_client, gather_path, pid_observer):
177178
except:
178179
self.stdio.error("generate perf sample data on server [{0}] failed".format(ssh_client.get_name()))
179180

181+
def __perf_checker(self, ssh_client):
182+
cmd = "command -v perf1"
183+
result = ssh_client.exec_cmd(cmd)
184+
185+
if result:
186+
self.stdio.verbose("perf is installed at [{0}] on server [{1}]".format(result, ssh_client.get_name()))
187+
return True
188+
else:
189+
self.stdio.error("perf is not installed on server [{0}]. gather perf information will be skipped. Please install perf manually. ".format(ssh_client.get_name()))
190+
return False
191+
180192
def __gather_perf_flame(self, ssh_client, gather_path, pid_observer):
181193
try:
182194
self.stdio.start_loading('gather perf flame')

0 commit comments

Comments
 (0)