获取OS信息:
1. os = " ".join(platform.linux_distribution())
2. os = subprocess.call([‘cat‘, ‘/etc/redhat-release‘])
获取主机平台
获取主机名
import socket
hostname = socket.gethostname()
获取CPU信息:
获取物理CPU个数
1. os.cpu_count()
2. psutil.cpu_count()
获取CPU型号
with open(‘/proc/cpuinfo‘) as f:
for line in f:
if line.startswith(‘model name‘):
server_cpu = line.split(":")[1].strip()