Skip to content

Commit

Permalink
Merge pull request #193 from Teingi/2.1.0_dev
Browse files Browse the repository at this point in the history
sysstat suport gather io/tcp/udp
  • Loading branch information
Teingi authored May 8, 2024
2 parents 4c052d3 + be9fdc2 commit 3f77a3c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 8 deletions.
4 changes: 2 additions & 2 deletions conf/inner_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ obdiag:
basic:
config_path: ~/.obdiag/config.yml
config_backup_dir: ~/.obdiag/backup_conf
file_number_limit: 20
file_size_limit: 2G
file_number_limit: 50
file_size_limit: 5G
dis_rsa_algorithms: 0
logger:
log_dir: ~/.obdiag/log
Expand Down
4 changes: 2 additions & 2 deletions handler/gather/gather_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ def __handle_log_list(self, ssh, node, resp):
resp["error"] = "Too many files {0} > {1}".format(len(log_list), self.file_number_limit)
return log_list, resp
elif len(log_list) <= 0:
self.stdio.warn('{0} The number of log files is {1}, The time range for file gather from {2} to {3}, and no eligible files were found'
"Please adjust the query time limit".format(ip, len(log_list), self.from_time_str, self.to_time_str))
self.stdio.warn('{0} The number of log files is {1}, The time range for file gather from {2} to {3}, and no eligible files were found.'
" Please adjust the query time limit.".format(ip, len(log_list), self.from_time_str, self.to_time_str))
resp["skip"] = True,
resp["error"] = "No files found"
return log_list, resp
Expand Down
4 changes: 2 additions & 2 deletions handler/gather/gather_obproxy_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ def __handle_log_list(self, ssh, node, resp):
resp["error"] = "Too many files {0} > {1}".format(len(log_list), self.file_number_limit)
return log_list, resp
elif len(log_list) <= 0:
self.stdio.warn("{0} The number of log files is {1}, The time range for file gather from {2} to {3}, and no eligible files were found"
"Please adjust the query time limit".format(ip, len(log_list), self.from_time_str, self.to_time_str))
self.stdio.warn("{0} The number of log files is {1}, The time range for file gather from {2} to {3}, and no eligible files were found."
" Please adjust the query time limit.".format(ip, len(log_list), self.from_time_str, self.to_time_str))
resp["skip"] = True,
resp["error"] = "No files found"
return log_list, resp
Expand Down
54 changes: 52 additions & 2 deletions handler/gather/gather_sysstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,13 @@ def __handle_from_node(self, node, local_stored_path):

self.__gather_dmesg_boot_info(ssh_helper, remote_dir_full_path)
self.__gather_dmesg_current_info(ssh_helper, remote_dir_full_path)
self.__gather_cpu_info(ssh_helper, remote_dir_full_path)
self.__gather_mem_info(ssh_helper, remote_dir_full_path)
if self.__tsar_exit(ssh_helper):
self.__gather_cpu_info(ssh_helper, remote_dir_full_path)
self.__gather_mem_info(ssh_helper, remote_dir_full_path)
self.__gather_swap_info(ssh_helper, remote_dir_full_path)
self.__gather_io_info(ssh_helper, remote_dir_full_path)
self.__gather_traffic_info(ssh_helper, remote_dir_full_path)
self.__gather_tcp_udp_info(ssh_helper, remote_dir_full_path)
zip_dir(self.is_ssh, ssh_helper, "/tmp", remote_dir_name, self.stdio)
remote_file_full_path = "{0}.zip".format(remote_dir_full_path)
file_size = get_file_size(self.is_ssh, ssh_helper, remote_file_full_path, self.stdio)
Expand Down Expand Up @@ -192,6 +197,15 @@ def __gather_dmesg_boot_info(self, ssh_helper, dir_path):
except:
self.stdio.error("Failed to gather the /var/log/dmesg on server {0}".format(ssh_helper.get_name()))

def __tsar_exit(self, ssh_helper):
try:
cmd = "tar --help"
exit = SshClient(self.stdio).run(ssh_helper, cmd) if self.is_ssh else LocalClient(self.stdio).run(cmd)
if exit:
return True
except:
self.stdio.warn("tsar not found")

def __gather_cpu_info(self, ssh_helper, gather_path):
try:
tsar_cmd = "tsar --cpu -i 1 > {gather_path}/one_day_cpu_data.txt".format(
Expand All @@ -210,6 +224,42 @@ def __gather_mem_info(self, ssh_helper, gather_path):
except:
self.stdio.error("Failed to gather memory info use tsar on server {0}".format(ssh_helper.get_name()))

def __gather_swap_info(self, ssh_helper, gather_path):
try:
tsar_cmd = "tsar --swap --load > {gather_path}/tsar_swap_data.txt".format(
gather_path=gather_path)
self.stdio.verbose("gather swap info on server {0}, run cmd = [{1}]".format(ssh_helper.get_name(), tsar_cmd))
SshClient(self.stdio).run(ssh_helper, tsar_cmd) if self.is_ssh else LocalClient(self.stdio).run(tsar_cmd)
except:
self.stdio.error("Failed to gather swap info use tsar on server {0}".format(ssh_helper.get_name()))

def __gather_io_info(self, ssh_helper, gather_path):
try:
tsar_cmd = "tsar --io > {gather_path}/tsar_io_data.txt".format(
gather_path=gather_path)
self.stdio.verbose("gather io info on server {0}, run cmd = [{1}]".format(ssh_helper.get_name(), tsar_cmd))
SshClient(self.stdio).run(ssh_helper, tsar_cmd) if self.is_ssh else LocalClient(self.stdio).run(tsar_cmd)
except:
self.stdio.error("Failed to gather io info use tsar on server {0}".format(ssh_helper.get_name()))

def __gather_traffic_info(self, ssh_helper, gather_path):
try:
tsar_cmd = "tsar --traffic > {gather_path}/tsar_traffic_data.txt".format(
gather_path=gather_path)
self.stdio.verbose("gather traffic info on server {0}, run cmd = [{1}]".format(ssh_helper.get_name(), tsar_cmd))
SshClient(self.stdio).run(ssh_helper, tsar_cmd) if self.is_ssh else LocalClient(self.stdio).run(tsar_cmd)
except:
self.stdio.error("Failed to gather traffic info use tsar on server {0}".format(ssh_helper.get_name()))

def __gather_tcp_udp_info(self, ssh_helper, gather_path):
try:
tsar_cmd = "tsar --tcp --udp -d 1 > {gather_path}/tsar_tcp_udp_data.txt".format(
gather_path=gather_path)
self.stdio.verbose("gather tcp and udp info on server {0}, run cmd = [{1}]".format(ssh_helper.get_name(), tsar_cmd))
SshClient(self.stdio).run(ssh_helper, tsar_cmd) if self.is_ssh else LocalClient(self.stdio).run(tsar_cmd)
except:
self.stdio.error("Failed to gather tcp and udp info use tsar on server {0}".format(ssh_helper.get_name()))

@staticmethod
def __get_overall_summary(node_summary_tuple):
summary_tab = []
Expand Down

0 comments on commit 3f77a3c

Please sign in to comment.