Linux下程式設計系統訊息之獲取

來源:互聯網
上載者:User

一、查看作業系統版本 

# uname -a

Linux apps-test-game 2.6.9-11.ELsmp #1 SMP Fri May 20 18:26:27 EDT 2005 i686 i68
6 i386 GNU/Linux



# cat /proc/version

Linux version 2.6.9-11.ELsmp (bhcompile@decompose.build.redhat.com) (gcc version
 3.4.3 20050227 (Red Hat 3.4.3-22)) #1 SMP Fri May 20 18:26:27 EDT 2005



# cat /etc/issue

Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
Kernel r on an m



#cat /etc/redhat-release

Red Hat Enterprise Linux AS release 4 (Nahant Update 1)

 

二、查看CPU

Linux下的CPU訊息放在/proc/cpuinfo檔案中,這個檔案裡面記錄了許多詳細的訊息,可以用fopen打開它或者用popen執行一條cat命令來得到結果。

#cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Xeon(TM) CPU 3.20GHz
stepping        : 10
cpu MHz         : 3200.847
cache size      : 2048 KB
physical id     : 0
siblings        : 2
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 sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm pni monitor ds_c
pl cid xtpr
bogomips        : 6275.07

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Xeon(TM) CPU 3.20GHz
stepping        : 10
cpu MHz         : 3200.847
cache size      : 2048 KB
physical id     : 0
siblings        : 2
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 sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm pni monitor ds_c
pl cid xtpr
bogomips        : 6389.76

processor       : 2
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Xeon(TM) CPU 3.20GHz
stepping        : 10
cpu MHz         : 3200.847
cache size      : 2048 KB
physical id     : 3
siblings        : 2
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 sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm pni monitor ds_c
pl cid xtpr
bogomips        : 6389.76

processor       : 3
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Xeon(TM) CPU 3.20GHz
stepping        : 10
cpu MHz         : 3200.847
cache size      : 2048 KB
physical id     : 3
siblings        : 2
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 sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm pni monitor ds_c
pl cid xtpr
bogomips        : 6389.76

CPU的完整訊息。

#cat /proc/cpuinfo | grep processor | wc -l
4

CPU計數,有4個CPU(可能為2個雙核的)。

 

三、查看(記憶體)內存訊息

與CPU一樣,Linux下的記憶體訊息放在/proc/meminfo檔案中,這個檔案裡面記錄了許多詳細的訊息,可以用fopen打開它或者用popen執行一條cat命令來得到結果。

比如:

#free
             total       used       free     shared    buffers     cached
Mem:       1034148     846312     187836          0      57304     418236
-/+ buffers/cache:     370772     663376
Swap:      2031608          0    2031608

或者:

#cat /proc/meminfo
MemTotal:      1034148 kB
MemFree:        188620 kB
Buffers:         57312 kB
Cached:         418228 kB
SwapCached:          0 kB
Active:         559084 kB
Inactive:       226244 kB
HighTotal:      130496 kB
HighFree:          252 kB
LowTotal:       903652 kB
LowFree:        188368 kB
SwapTotal:     2031608 kB
SwapFree:      2031608 kB
Dirty:              60 kB
Writeback:           0 kB
Mapped:         364944 kB
Slab:            49184 kB
Committed_AS:   487816 kB
PageTables:       2832 kB
VmallocTotal:   106488 kB
VmallocUsed:      3504 kB
VmallocChunk:   102648 kB
HugePages_Total:     0
HugePages_Free:      0
Hugepagesize:     2048 kB
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.