# 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