歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux管理 >> Linux服務 >> Linux服務器監控命令

Linux服務器監控命令

日期:2017/3/3 16:58:00   编辑:Linux服務

(1) iostat

這個命令可以檢測存儲設備是否工作正常,顯示存儲系統的細節,可以看到每個磁盤的IO情況,也可以監控到CPU 的使用狀態.

14:52 [root@aaa]$ iostat
Linux 2.6.18-308.el5 (aaa) 2014年08月22日

avg-cpu: %user %nice %system %iowait %steal %idle
4.65 0.00 0.78 0.02 0.00 94.55

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 1.55 0.16 96.24 5548422 3391975158
sda1 0.00 0.00 0.00 1748 118
sda2 0.71 0.13 27.18 4537378 957989784
sda3 0.00 0.00 0.00 1422 304
sda4 0.00 0.00 0.00 8 0
sda5 0.83 0.03 69.06 1007434 2433984952

(2)free查看內存使用情況的綜述

14:56 [root@a ]$ free -m
total used free shared buffers cached
Mem: 32168 31714 453 0 1056 26763
-/+ buffers/cache: 3894 28273
Swap: 4094 0 4094

(3)meminfo查看詳細信息

14:52 [root@aaa]$ cat /proc/meminfo
MemTotal: 32940052 kB
MemFree: 464180 kB
Buffers: 1081628 kB
Cached: 27405336 kB
SwapCached: 0 kB
Active: 6155648 kB
Inactive: 24833068 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 32940052 kB
LowFree: 464180 kB
SwapTotal: 4192956 kB
SwapFree: 4192804 kB
Dirty: 16 kB
Writeback: 0 kB
AnonPages: 2501732 kB
Mapped: 32108 kB
Slab: 1428392 kB
PageTables: 26956 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 20662980 kB
Committed_AS: 4767104 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 264924 kB
VmallocChunk: 34359473015 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 2048 kB

(4)mpstat 顯示CPU狀態,

可以顯示所有處理器的平均狀況,也可以顯示統計信息

12:38 [ ]$ mpstat -P ALL
Linux 2.6.18-308.el5 (a04.api.cms.3g.b28.youku) 2014年08月23日

12時38分01秒 CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
12時38分01秒 all 4.64 0.00 0.54 0.02 0.01 0.22 0.00 94.56 67.60
12時38分01秒 0 8.58 0.00 0.93 0.05 0.05 0.71 0.00 89.68 67.60
12時38分01秒 1 3.53 0.00 0.41 0.01 0.00 0.07 0.00 95.98 0.00
12時38分01秒 2 2.84 0.00 0.33 0.01 0.00 0.05 0.00 96.76 0.00
12時38分01秒 3 3.61 0.00 0.48 0.02 0.00 0.07 0.00 95.83 0.00

12:38 [[email protected]]$ mpstat -P 0
Linux 2.6.18-308.el5 () 2014年08月23日

12時40分43秒 CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
12時40分43秒 0 8.58 0.00 0.93 0.05 0.05 0.71 0.00 89.68 67.60

1 CPU:處理器編號,如果為all,則此行表示的是所有處理器的統計平均值
2 %usr:用戶態的CPU利用率
3 %nice:具有調度優先級的用戶態CPU利用率
4 %sys:內核態CPU利用率(此值不包括響應硬件中斷和軟件中斷的時間)
5 %iowait:處理IO請求導致CPU處於IDLE狀態的時間百分比
6 %irq:CPU響應硬件中斷的時間比率
7 %soft:CPU響應軟件中斷的時間比率
8 %steal:當虛擬機監控器在服務於其他虛擬處理器時,虛擬CPU的被動等待時間比率
9 %guest:運行一個虛擬處理器所消耗的CPU時間比率

(5)netstat
-a : 顯示所有socke信息
-r : 顯示路由信息
-i : 顯示網卡借口統計
-s : 顯示網絡協議統計

(6)pmap 顯示進程占用的內存量,找到占用內存最多的進程.
nginx主進程內存占用情況分析

15:00 [ ]$ ps -ef | grep nginx
nobody 13609 19402 0 Aug06 ? 00:00:00 nginx: worker process
nobody 13610 19402 0 Aug06 ? 00:00:00 nginx: worker process
nobody 13611 19402 0 Aug06 ? 00:00:00 nginx: worker process
nobody 13612 19402 0 Aug06 ? 00:00:00 nginx: worker process
nobody 13613 19402 0 Aug06 ? 00:00:00 nginx: worker process
nobody 13614 19402 0 Aug06 ? 00:00:00 nginx: worker process
nobody 13615 19402 0 Aug06 ? 00:00:01 nginx: worker process
nobody 13616 19402 0 Aug06 ? 00:00:01 nginx: worker process
root 16487 16097 0 15:00 pts/1 00:00:00 grep nginx
root 19402 1 0 May05 ? 00:00:00 nginx: master process nginx

15:00 [ ]$ pmap 19402|head -n 10
19402: nginx: master process nginx
0000000000400000 1112K r-x– /opt/nginx/sbin/nginx
0000000000716000 68K rw— /opt/nginx/sbin/nginx
0000000000727000 60K rw— [ anon ]
0000000014fbc000 1080K rw— [ anon ]
0000003243200000 1204K r-x– /lib64/libcrypto.so.0.9.8e.#prelink#.6Zb7wz (deleted)
000000324332d000 2044K —– /lib64/libcrypto.so.0.9.8e.#prelink#.6Zb7wz (deleted)
000000324352c000 132K rw— /lib64/libcrypto.so.0.9.8e.#prelink#.6Zb7wz (deleted)
000000324354d000 16K rw— [ anon ]
0000003243600000 280K r-x– /lib64/libssl.so.0.9.8e

Copyright © Linux教程網 All Rights Reserved