2020
10-15
10-15
python获取linux系统信息的三种方法
方法一:psutil模块#!usr/bin/envpython#-*-coding:utf-8-*-importsocketimportpsutilclassNodeResource(object):defget_host_info(self):host_name=socket.gethostname()return{'host_name':host_name}defget_cpu_state(self):cpu_count=psutil.cpu_count(logical=False)cpu_percent=(str)(psutil.cpu_percent(1))+'%'return{'cpu_count':cpu_count,'cpu_percent':cpu_percent}defget_memory_stat...
继续阅读 >