天天看點

linux伺服器狀态檢視指令,詳細的Linux伺服器狀态、性能相關指令

伺服器狀态分析

檢視Linux伺服器CPU詳細情況

#檢視CPU的資訊

[[email protected] ~]# cat /proc/cpuinfo

#檢視實體CPU的個數

[[email protected] /]# cat /proc/cpuinfo | grep"physical id"| sort | uniq | wc -l

#檢視每個實體CPU的核數

[[email protected] /]# cat /proc/cpuinfo | grep"cpu cores"| uniq

#邏輯CPU的個數(邏輯CPU = 實體CPU個數*核數)

[[email protected] /]# cat /proc/cpuinfo | grep"processor"| wc -l

linux伺服器狀态檢視指令,詳細的Linux伺服器狀态、性能相關指令

檢視Linux伺服器記憶體情況

#檢視記憶體使用情況

[[email protected] ~]#free-m

total used freeshared buffers cached

Mem: 372 256 115 0 17 158

-/+ buffers/cache: 81 290

Swap: 509 0 509

>total:記憶體總數

>user:已使用記憶體數

>free:空閑記憶體數

>shared:多程序共享記憶體數

>buffers:緩沖記憶體數

>cached:緩存記憶體數

可用記憶體 = free+buffers+cached

已用記憶體 = used-buffers-cached

swap 交換記憶體數,此項可判斷記憶體是否夠用的标準

檢視Linux伺服器硬碟使用情況

#檢視硬碟及分區資訊

fdisk -l

[[email protected] ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of16065 * 512 = 8225280 bytes

Device Boot Start EndBlocks Id System

/dev/sda1 * 1 13 104391 83 Linux

/dev/sda2 14 78 522112+ 82 Linux swap / Solaris

/dev/sda3 79 1305 9855877+ 83 Linux

#檢查檔案系統的磁盤空間占用情況

df -h

[[email protected] ~]# df -h

Filesystem SizeUsed Avail Use% Mountedon

/dev/sda3 9.2G 6.4G 2.3G 74% /

/dev/sda1 99M 12M 82M 13% /boot

tmpfs 187M 0 187M 0% /dev/shm

/dev/hdc 4.1G 4.1G 0 100% /mnt

linux伺服器狀态檢視指令,詳細的Linux伺服器狀态、性能相關指令

伺服器性能分析

#檢視硬碟的I/O性能

[[email protected] /]# iostat -d -x -k 1 5

#iostaat是含在套裝systat中,在CentOs5.5用指令yum -y install sysstat來安裝

linux伺服器狀态檢視指令,詳細的Linux伺服器狀态、性能相關指令

I/0

檢視Linux伺服器的平均負載

[[email protected] /]# uptime

12:39:12 up 2:50, 3 users, loadaverage: 0.00, 0.03, 0.00

linux伺服器狀态檢視指令,詳細的Linux伺服器狀态、性能相關指令

[[email protected] /]# w

12:39:59 up 2:50, 3 users, loadaverage: 0.00, 0.03, 0.00

USERTTYFROMLOGIN@ IDLE JCPU PCPU WHAT

root tty1 - 09:53 32:17 0.36s 0.36s -bash

root pts/0 192.168.1.102 10:23 1:54m 0.03s 0.03s -bash

root pts/1 192.168.1.105 12:16 0.00s 0.09s 0.02s w

監控Linux伺服器的整體性能

linux伺服器狀态檢視指令,詳細的Linux伺服器狀态、性能相關指令

整體性能

[[email protected] /]# vmstat 1 4

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------

r b swpd freebuff cache si so bi boincs us sy id wa st

0 0 0 50464 50096 101356 0 0 21 13 925 183 0 0 99 1 0

0 0 0 50464 50096 101380 0 0 0 0 830 18 0 0 100 0 0

0 0 0 50464 50096 101380 0 0 0 0 833 27 0 0 100 0 0

0 0 0 50464 50104 101372 0 0 0 32 822 27 0 0 99 1 0

#proces r:等待運作的程序數 b:非中斷睡眠狀态的程序數 w:被交換出去的可運作程序數

#memory swpd:虛拟記憶體使用情況 fres:空閑的記憶體 buff:用作緩存的記憶體數(機關:KB)

#swap si:從磁盤交換到記憶體的交換頁數量 so:從記憶體交換到磁盤的交換頁數量(機關:kb/秒)

#io bi:發送到塊裝置的塊數 bo:從塊裝置接收到的塊數(機關:塊/秒)

#system in:每秒的中斷數,包括時鐘中斷 cs:每秒的環境(上下文)切換數

#cpu us:CPU使用時間 sy:CPU系統使用時間 id:閑置時間(機關:百分比)

标準情況下:r小于5,b約為0

如果user + sys 小于70 表示系統性能較好;如果大于等于85以上,表示性能比較糟糕

檢視Linux伺服器的其他參數

檢視系統核心的版本号

[[email protected] /]# uname -a

Linux host.domain.com 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

[[email protected] /]# uname -r

2.6.18-194.el5

檢視系統32位還是64位

[[email protected] /]# ls -1F / |grep /$

查找是否有/lib64,有則系統為64位

另一種檢視系統32位還是64位

[[email protected] /]# file /sbin/init

/sbin/init: ELF 64-bitLSB executable, AMD x86-64, version 1 (SYSV),forGNU/Linux 2.6.9, dynamically linked (uses shared libs),forGNU/Linux 2.6.9, stripped

檢視伺服器使用的Linux發行版的相關資訊

[[email protected] /]# lsb_release -a

LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch

Distributor ID: CentOS

Description: CentOS release 5.5 (Final)

Release: 5.5

Codename: Final

檢視系統已載入的相關子產品

[[email protected] /]# lsmod |grep ip

ipv6 435361 24

xfrm_nalgo 43333 1 ipv6

dm_multipath 56920 0

scsi_dh 42177 1 dm_multipath

dm_mod 101649 4 dm_mirror,dm_multipath,dm_raid45,dm_log

在linux下檢視PCI設定,lspci指令能列出機器中的PCI資訊,比如聲霸卡、顯示卡、Modem

[[email protected] /]# lspci | grep Ether

02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)

【編輯推薦】

【責任編輯:武曉燕 TEL:(010)68476606】