LinuxやFreeBSDでCPUやメモリの情報を調べる

LinuxFreeBSDでCPU情報とかの取得を良く忘れてしまうのでメモ。特にFreeBSDは/var/log/dmesg.todayでしか見れないと昔思っていたので、しょっちゅう忘れてしまう。

Linuxの場合

/procディレクトリの下にあるファイルに一通り入っている。CPUの場合はcpuinfoを見ればよい

% cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping        : 3
cpu MHz         : 3000.422
cache size      : 2048 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc up pni monitor ds_cpl est cid cx16 xtpr
bogomips        : 6003.37

メモリの場合はmeminfo

% cat /proc/meminfo
MemTotal:      2066532 kB
MemFree:         66236 kB
Buffers:        297088 kB
Cached:        1166636 kB
SwapCached:        808 kB
Active:        1289804 kB
Inactive:       556984 kB
HighTotal:     1170368 kB
HighFree:        11512 kB
LowTotal:       896164 kB
LowFree:         54724 kB
SwapTotal:     2031608 kB
SwapFree:      2029840 kB
Dirty:             848 kB
Writeback:           0 kB
AnonPages:      382244 kB
Mapped:          28732 kB
Slab:           143656 kB
PageTables:       2964 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   3064872 kB
Committed_AS:   657972 kB
VmallocTotal:   114680 kB
VmallocUsed:      3352 kB
VmallocChunk:   111188 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     4096 kB

FreeBSDの場合

% cat /var/run/dmesg.boot
Copyright (c) 1992-2008 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
       The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 7.0-RELEASE #1: Tue Oct 14 07:58:04 UTC 2008
   root@:/usr/src/sys/i386/compile/LSA_ROUTER
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Pentium(R) III CPU family      1400MHz (1396.03-MHz 686-class CPU)
 Origin = "GenuineIntel"  Id = 0x6b1  Stepping = 1
 Features=0x383fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE>
real memory  = 1610547200 (1535 MB)
avail memory = 1568739328 (1496 MB)
ACPI APIC Table: <VIA694 AWRDACPI>
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
cpu0 (BSP): APIC ID:  0
cpu1 (AP): APIC ID:  1
.
.
.