在Linux操作系统中,/proc 是一个虚拟的目录,它是系统内存的映射,我们可以通过直接访问这个目录来获取系统信息,例如我们可以使用 cat /proc/cpuinfo 查看CPU信息。然而在macOSX系统中,由于系统实现机制的原因,并没有提供此功能,所以此命令不可用。

为了实现此功能,我们直接查看系统信息,也可以使用一些命令获得系统的基本硬件信息,如:

haodeMacBook-Pro:java hao$ system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro15,1
      Processor Name: Intel Core i7
      Processor Speed: 2.2 GHz
      Number of Processors: 1
      Total Number of Cores: 6
      L2 Cache (per Core): 256 KB
      L3 Cache: 9 MB
      Memory: 32 GB
      Boot ROM Version: 220.240.2.0.0 (iBridge: 16.16.3133.0.0,0)
      Serial Number (system): C02X606NJGH5
      Hardware UUID: B0D3DA8E-4C62-53A7-893F-67611180EEC2

但是,这些信息过于简单,如果我们需要更详细的信息,如CPU的型号信息,或者线程数就无能为力了。

不过好在系统提供了另外一个可能的命令 sysctl,如:

  • $ sysctl machdep.cpu.brand_string
    返回CPU品牌信息。

除了可以使用参数 machdep.cpu.brand_string 查看CPU品牌信息,以下列出所有可用参数,并附上在我的 MacBook Pro 2018上的输出结果。
在这里插入图片描述

以下为详细列表

hw.activecpu: 12
hw.busfrequency: 400000000
hw.busfrequency_max: 400000000
hw.busfrequency_min: 400000000
hw.byteorder: 1234
hw.cacheconfig: 12 2 2 12 0 0 0 0 0 0
hw.cachelinesize: 64
hw.cachesize: 34359738368 32768 262144 9437184 0 0 0 0 0 0
hw.cpu64bit_capable: 1
hw.cpufamily: 260141638
hw.cpufrequency: 2200000000
hw.cpufrequency_max: 2200000000
hw.cpufrequency_min: 2200000000
hw.cpusubtype: 8
hw.cputhreadtype: 1
hw.cputype: 7
hw.l1dcachesize: 32768
hw.l1icachesize: 32768
hw.l2cachesize: 262144
hw.l3cachesize: 9437184
hw.logicalcpu: 12
hw.logicalcpu_max: 12
hw.memsize: 34359738368
hw.ncpu: 12
hw.packages: 1
hw.pagesize: 4096
hw.physicalcpu: 6
hw.physicalcpu_max: 6
hw.tbfrequency: 1000000000
kern.argmax: 262144
kern.bootargs: 
kern.boottime: { sec = 1555831007, usec = 348628 } Sun Apr 21 15:16:47 2019
kern.clockrate: { hz = 100, tick = 10000, tickadj = 0, profhz = 100, stathz = 100 }
kern.coredump: 1
kern.corefile: /cores/core.%P
kern.flush_cache_on_write: 0
kern.hostid: 0
kern.hostname: haodeMacBook-Pro.local
kern.job_control: 1
kern.maxfiles: 98304
kern.maxfilesperproc: 49152
kern.maxnbuf: 16384
kern.maxproc: 4256
kern.maxprocperuid: 2837
kern.maxvnodes: 263168
kern.msgbuf: 16384
kern.nbuf: 16384
kern.netboot: 0
kern.ngroups: 16
kern.nisdomainname: 
kern.num_files: 5645
kern.num_tasks: 8192
kern.num_taskthreads: 8192
kern.num_threads: 40960
kern.num_vnodes: 263168
kern.nx: 1
kern.osrelease: 18.2.0
kern.osrevision: 199506
kern.ostype: Darwin
kern.osversion: 18D109
kern.posix1version: 200112
kern.procname: sysctl
kern.safeboot: 0
kern.saved_ids: 1
kern.secure_kernel: 0
kern.securelevel: 0
kern.singleuser: 0
kern.sleeptime: { sec = 1558779450, usec = 38866 } Sat May 25 18:17:30 2019
kern.slide: 1
kern.stack_depth_max: 10704
kern.stack_size: 16384
kern.sugid_coredump: 0
kern.sugid_scripts: 0
kern.usrstack: -433528832
kern.usrstack64: 140732759859200
kern.uuid: 1970B070-E53F-3178-83F3-1B95FA340695
kern.version: Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64
kern.waketime: { sec = 1558779640, usec = 668566 } Sat May 25 18:20:40 2019
machdep.cpu.address_bits.physical: 39
machdep.cpu.address_bits.virtual: 48
machdep.cpu.brand: 0
machdep.cpu.brand_string: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
machdep.cpu.cache.L2_associativity: 4
machdep.cpu.cache.linesize: 64
machdep.cpu.cache.size: 256
machdep.cpu.core_count: 6
machdep.cpu.cores_per_package: 8
machdep.cpu.extfamily: 0
machdep.cpu.extfeature_bits: 1241984796928
machdep.cpu.extfeatures: SYSCALL XD 1GBPAGE EM64T LAHF LZCNT PREFETCHW RDTSCP TSCI
machdep.cpu.extmodel: 9
machdep.cpu.family: 6
machdep.cpu.feature_bits: 9221959987971750911
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C
machdep.cpu.leaf7_feature_bits: 43804591
machdep.cpu.leaf7_features: SMEP ERMS RDWRFSGS TSC_THREAD_OFFSET BMI1 AVX2 BMI2 INVPCID SMAP RDSEED ADX IPT SGX FPU_CSDS MPX CLFSOPT
machdep.cpu.logical_per_package: 16
machdep.cpu.max_basic: 22
machdep.cpu.max_ext: 2147483656
machdep.cpu.microcode_version: 150
machdep.cpu.model: 158
machdep.cpu.processor_flag: 5
machdep.cpu.signature: 591594
machdep.cpu.stepping: 10
machdep.cpu.thread_count: 12
machdep.cpu.tlb.data.small: 64
machdep.cpu.tlb.data.small_level1: 64
machdep.cpu.tlb.inst.large: 8
machdep.cpu.vendor: GenuineIntel
machdep.cpu.xsave.extended_state: 31 832 1088 0
machdep.tsc.deep_idle_rebase: 1
machdep.tsc.frequency: 2208000000
machdep.tsc.nanotime.generation: 840
machdep.tsc.nanotime.shift: 0
net.inet.ip.forwarding: 0
net.inet.ip.portrange.first: 49152
net.inet.ip.portrange.hifirst: 49152
net.inet.ip.portrange.hilast: 65535
net.inet.ip.portrange.last: 65535
net.inet.ip.portrange.lowfirst: 1023
net.inet.ip.portrange.lowlast: 600
net.inet.ip.redirect: 1
net.inet.ip.ttl: 64
net.inet.udp.checksum: 1
net.inet.udp.maxdgram: 9216
vm.loadavg: { 1.66 1.62 1.58 }
vm.swapusage: total = 4096.00M  used = 2860.00M  free = 1236.00M  (encrypted)
user.bc_base_max: 99
user.bc_dim_max: 2048
user.bc_scale_max: 99
user.bc_string_max: 1000
user.coll_weights_max: 2
user.cs_path: /usr/bin:/bin:/usr/sbin:/sbin
user.expr_nest_max: 32
user.line_max: 2048
user.posix2_c_bind: 0
user.posix2_c_dev: 0
user.posix2_char_term: 0
user.posix2_fort_dev: 0
user.posix2_fort_run: 0
user.posix2_localedef: 0
user.posix2_sw_dev: 0
user.posix2_upe: 0
user.posix2_version: 200112
user.re_dup_max: 255
user.stream_max: 20
user.tzname_max: 255
GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐