def _get_system_status(self):
system_uptime_value = TimeFormatter.format(self.__get_elapsed_seconds_since(psutil.boot_time()))
system_uptime = FormattedText()\
.normal("Uptime: {system_uptime}").start_format().bold(system_uptime=system_uptime_value).end_format()
cpu_usage_value = str(psutil.cpu_percent(interval=self.cpu_usage_sample_seconds)) + " %"
cpu_usage = FormattedText()\
.normal("CPU usage: {cpu_usage} ({sample_interval} sec. sample)").start_format()\
.bold(cpu_usage=cpu_usage_value).normal(sample_interval=self.cpu_usage_sample_seconds).end_format()
return FormattedText().newline().join((
FormattedText().bold("System status"),
system_uptime,
cpu_usage
))
评论列表
文章目录