Skip to content

Commit

Permalink
Add a check to verify if perf is installed on the system when gather …
Browse files Browse the repository at this point in the history
…perf (#633)

* Rename Dockerfile to DockerFile

* fix

* fix

* fixed: issue #620

* fixed: issue #620

* fixed: issue #620
  • Loading branch information
Teingi authored Dec 16, 2024
1 parent b67cfbb commit f1a20e3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Empty file modified dev_helper.sh
100644 → 100755
Empty file.
26 changes: 19 additions & 7 deletions src/handler/gather/gather_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ def __handle_from_node(self, node, local_stored_path):
resp["error"] = "can't find observer"
return resp
for pid_observer in pid_observer_list:
if self.scope == "sample":
self.__gather_perf_sample(ssh_client, remote_dir_full_path, pid_observer)
elif self.scope == "flame":
self.__gather_perf_flame(ssh_client, remote_dir_full_path, pid_observer)
else:
self.__gather_perf_sample(ssh_client, remote_dir_full_path, pid_observer)
self.__gather_perf_flame(ssh_client, remote_dir_full_path, pid_observer)
if self.__perf_checker(ssh_client):
if self.scope == "sample":
self.__gather_perf_sample(ssh_client, remote_dir_full_path, pid_observer)
elif self.scope == "flame":
self.__gather_perf_flame(ssh_client, remote_dir_full_path, pid_observer)
else:
self.__gather_perf_sample(ssh_client, remote_dir_full_path, pid_observer)
self.__gather_perf_flame(ssh_client, remote_dir_full_path, pid_observer)
self.__gather_top(ssh_client, remote_dir_full_path, pid_observer)

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

def __perf_checker(self, ssh_client):
cmd = "command -v perf1"
result = ssh_client.exec_cmd(cmd)

if result:
self.stdio.verbose("perf is installed at [{0}] on server [{1}]".format(result, ssh_client.get_name()))
return True
else:
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()))
return False

def __gather_perf_flame(self, ssh_client, gather_path, pid_observer):
try:
self.stdio.start_loading('gather perf flame')
Expand Down

0 comments on commit f1a20e3

Please sign in to comment.