# cat cpu_info.py #!/usr/bin/env python # -*- coding: utf-8 -*- # ldczz2008@163.com import os import sigar sg = sigar.open() cpulist = sg.cpu_info_list() print "%d total CPUs." % len(cpulist) for cpu in cpulist: print "Vendor........", cpu.vendor() print "Model.........", cpu.model() print "Mhz...........", cpu.mhz() print "Cache size....", cpu.cache_size() sg.close()
运行效果为:
# python cpu_info.py 1 total CPUs. Vendor........ Intel Model......... Core(TM) i5-2410M CPU @ 2.30GHz Mhz........... 2333 Cache size.... 6144
本文出自 “天道酬勤” 博客,请务必保留此出处http://lavenliu.blog.51cto.com/5060944/1709962
sigar模块之python api简单的使用--获取cpu信息
原文地址:http://lavenliu.blog.51cto.com/5060944/1709962