linux 常用命令收集

查看内存:

       [root@host ~]# free -m

total used free shared buffers cached
Mem: 1024 1005 19 0 9 782
-/+ buffers/cache: 212 811
Swap: 996 0 995
[root@host ~]#
从上看出这个Linux系统一共有内存1024M,但当前Linux 系统已经占用的内存有多少呢?大多数用户的答案是1005M,其实不然。
当前VPS占用的内存应该是212M,也就是1005下面那个数字:212,代表已经占用的内存。后面的那个811,代表当前Linux系统的可用内存。
"-/+ buffers/cache:"开头的这行才是实际的占用内存和可用内存。
所以,看内存使用情况,应该看"-/+ buffers/cache:"开头的这一行,如果这一行最后的数字接近0,那么说明Linux系统的内存快用完了,这时候Linux系统反应就比较慢。如果这个数字还比较大,那么Linux系统还有较多内存可用,系统不应该慢。

查看CPU:

              很多人都知道, 直接敲 cat /proc/cpuinfo 可以看到详细的cpu信息.

信息里会分processor 0 -n, 如果你认为n就是cpu真实核数的话, 就大错特错了.

我们知道intel有超线程技术(HT), 它可以在逻辑上分一倍数量的cpu出来.所以, 光看processor数量是不准的.

真实的核数, 应该是 cpu cores 这个参数值.

 

[admin@transmit180 logs]$ cat /proc/cpuinfo

processor       : 0

vendor_id       : GenuineIntel

cpu family      : 6

model           : 15

model name      : Intel(R) Xeon(R) CPU           E5310  @ 1.60GHz

stepping        : 7

cpu MHz         : 1596.035

cache size      : 4096 KB

physical id     : 0

siblings        : 4

core id         : 0

cpu cores       : 4

fdiv_bug        : no

hlt_bug         : no

f00f_bug        : no

coma_bug        : no

fpu             : yes

fpu_exception   : yes

cpuid level     : 10

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 constant_tsc pni monitor ds_cpl tm2 xtpr

bogomips        : 3194.26

 

物理cpu数量,可以数不重复的 physical id 有几个。

查看机器使用情况:

        root@iZ25hkx7nczZ:~# top

        top - 08:27:50 up 45 days, 10:47,  1 user,  load average: 0.00, 0.01, 0.05

Tasks:  68 total,   1 running,  67 sleeping,   0 stopped,   0 zombie

Cpu(s):  0.3%us,  0.3%sy,  0.0%ni, 99.3%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Mem:   1017972k total,   922256k used,    95716k free,    58632k buffers

Swap:        0k total,        0k used,        0k free,    39804k cached

 

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                

 1477 root      20   0  660m 6692 2992 S  0.7  0.7  99:39.64 AliYunDun                                                              

10969 zhangxf   20   0 1651m 334m  724 S  0.7 33.6  85:24.29 java                                                                   

 2715 root      20   0 1004m 209m 1192 S  0.3 21.0  39:58.38 java                                                                   

10967 zhangxf   20   0 17792  536  368 S  0.3  0.1  25:28.14 wrapper                                                                

    1 root      20   0 24212 1500  664 S  0.0  0.1   0:01.29 init                                                                   

    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd                                                               

    3 root      20   0     0    0    0 S  0.0  0.0   2:05.13 ksoftirqd/0                                                            

    5 root      20   0     0    0    0 S  0.0  0.0   0:00.20 kworker/u:0                                                            

    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                            

    7 root      RT   0     0    0    0 S  0.0  0.0   0:14.87 watchdog/0                                                             

    8 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 cpuset                                                                 

    9 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 khelper                                                                

   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kdevtmpfs                                                              

   11 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 netns                                                                  

   12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 xenwatch                                                               

   13 root      20   0     0    0    0 S  0.0  0.0   0:00.02 xenbus                                                                 

   14 root      20   0     0    0    0 S  0.0  0.0   0:03.78 sync_supers                                                            

   15 root      20   0     0    0    0 S  0.0  0.0   0:00.20 bdi-default                                                            

   16 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kintegrityd                                                            

   17 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kblockd                                                                

   18 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 ata_sff                                                                

   19 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khubd                                                                  

   20 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 md                                                                     

   21 root      20   0     0    0    0 S  0.0  0.0   0:01.52 kworker/u:1                                                            

   22 root      20   0     0    0    0 S  0.0  0.0   4:09.96 kworker/0:1                                                            

   24 root      20   0     0    0    0 S  0.0  0.0   0:01.33 khungtaskd                                                             

   25 root      20   0     0    0    0 S  0.0  0.0   0:08.22 kswapd0                                                                

   26 root      25   5     0    0    0 S  0.0  0.0   0:00.00 ksmd                                                                   

   27 root      39  19     0    0    0 S  0.0  0.0   0:00.00 khugepaged                                                             

   28 root      20   0     0    0    0 S  0.0  0.0   0:00.00 fsnotify_mark                                                          

   29 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ecryptfs-kthrea                                                        

   30 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 crypto                                                                 

   38 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kthrotld                                                               

   39 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_0                                                              

   40 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_1                                                              

   61 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 devfreq_

猜你喜欢

转载自zh-ka-163-com.iteye.com/blog/2214624