diff --git a/dev_helper.sh b/dev_helper.sh old mode 100644 new mode 100755 diff --git a/src/handler/gather/gather_perf.py b/src/handler/gather/gather_perf.py index d3da96d..6418d74 100644 --- a/src/handler/gather/gather_perf.py +++ b/src/handler/gather/gather_perf.py @@ -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) @@ -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')