Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check to verify if perf is installed on the system when gather perf #633

Merged
merged 10 commits into from
Dec 16, 2024
Merged
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
Loading