Linux server status, performance related commands

---------View Linux server CPU details---------------

#View CPU information

[root@host ~]# cat /proc/cpuinfo 

#Check the number of physical CPUs

[root@host /]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l

#View the number of cores per physical CPU

[root@host /]# cat /proc/cpuinfo | grep "cpu cores" | uniq

#Number of logical CPUs (logical CPU = number of physical CPUs * number of cores)

[root@host /]# cat /proc/cpuinfo | grep "processor" | wc -l

---------Check the memory of the Linux server---------------

#View memory usage

[root@host ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           372        256        115          0         17        158
-/+ buffers/cache:         81        290
Swap:          509          0        509

>total: total memory

>user: the number of memory used

>free: number of free memory

>shared: the number of shared memory for multiple processes

>buffers: the number of buffer memory

>cached: the number of cache memory
available memory = free+buffers+cached
used memory = used-buffers-cached
swap number of swap memory, this item can judge whether the memory is sufficient

---------View Linux server hard disk usage-------------

#View hard disk and partition information

[root@host ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   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

#Check the disk space usage of the file system

[root@host ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/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

#查看硬盘的I/O性能

[root@host /]# iostat -d -x -k 1 5
#iostaat是含在套装systat中,在CentOs5.5用命令yum -y install sysstat来安装

#查看指定目录的大小

[root@host /]# du -sh /bin/
7.8M    /bin/

#查看当前目录下的文件占用率

[root@host /]# du -cks * | sort -rn |head -n 10
10953077    total
4442100    var
4289198    mnt
1790236    usr
152848    etc
132080    lib
65604    swapfile
34184    sbin
20804    lib64
9840    tftpboot

#将指定的输入文件复制到指定的输出文件中

#利用dd命令可以制作交换文件

[root@host /]# dd if=/dev/zero of=/sampfile bs=1024 count=65536
65536+0 records in
65536+0 records out
67108864 bytes (67 MB) copied, 1.04575 seconds, 64.2 MB/s

#制作ISO

[root@host /]# dd if=/dev/cdrom of=/root/cd1.iso

---------查看Linux服务器的平均负载--------------

[root@host /]# uptime
 12:39:12 up  2:50,  3 users,  load average: 0.00, 0.03, 0.00
[root@host /]# w
 12:39:59 up  2:50,  3 users,  load average: 0.00, 0.03, 0.00
USER     TTY      FROM              LOGIN@   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服务器的整体性能--------------

[root@host /]# vmstat 1 4
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs 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服务器的其他参数--------------

 查看系统内核的版本号

[root@host /]# 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
[root@host /]# uname -r
2.6.18-194.el5

查看系统32位还是64位

[root@host /]# ls -1F / |grep /$
查找是否有/lib64,有则系统为64位
另一种查看系统32位还是64位
[root@host /]# file /sbin/init
/sbin/init: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

查看服务器使用的Linux发行版的相关信息

[root@host /]# 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

查看系统已载入的相关模块

[root@host /]# 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

[root@host /]# lspci | grep Ether
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326995770&siteId=291194637