1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 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() |
运行效果为:
1 2 3 4 5 6 | # python cpu_info.py 1 total CPUs. Vendor........ Intel Model......... Core(TM) i5-2410M CPU @ 2.30GHz Mhz........... 2333 Cache size.... 6144 |