• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 87  文章 - 279  trackbacks - 0
            <2010年7月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            潛心看書研究!

            常用鏈接

            留言簿(19)

            隨筆分類(81)

            文章分類(89)

            相冊

            ACM OJ

            My friends

            搜索

            •  

            積分與排名

            • 積分 - 216400
            • 排名 - 117

            最新評論

            閱讀排行榜

            評論排行榜


            1:查看CPU負載--mpstat
            mpstat -P ALL [internal [count]]

            參數的含義如下:
            -P ALL 表示監控所有CPU
            internal 相鄰的兩次采樣的間隔時間
            count 采樣的次數

            mpstat命令從/proc/stat獲得數據輸出
            輸出的含義如下:


            CPU 處理器ID
            user 在internal時間段里,用戶態的CPU時間(%) ,不包含 nice值為負 進程 ?usr/?total*100
            nice 在internal時間段里,nice值為負進程的CPU時間(%) ?nice/?total*100
            system 在internal時間段里,核心時間(%) ?system/?total*100
            iowait 在internal時間段里,硬盤IO等待時間(%) ?iowait/?total*100
            irq 在internal時間段里,軟中斷時間(%) ?irq/?total*100
            soft 在internal時間段里,軟中斷時間(%) ?softirq/?total*100
            idle 在internal時間段里,CPU除去等待磁盤IO操作外的因為任何原因而空閑的時間閑置時間 (%) ?idle/?total*100

            intr/s 在internal時間段里,每秒CPU接收的中斷的次數 ?intr/?total*100
            CPU總的工作時間total_cur=user+system+nice+idle+iowait+irq+softirq

            total_pre=pre_user+ pre_system+ pre_nice+ pre_idle+ pre_iowait+ pre_irq+ pre_softirq
            user=user_cur – user_pre
            total=total_cur-total_pre

            其中_cur 表示當前值,_pre表示interval時間前的值。上表中的所有值可取到兩位小數點。

            2:查看磁盤io情況及CPU負載--vmstat
            usage: vmstat [-V] [-n] [delay [count]]
                          -V prints version.
                          -n causes the headers not to be reprinted regularly.
                          -a print inactive/active page stats.
                          -d prints disk statistics
                          -D prints disk table
                          -p prints disk partition statistics
                          -s prints vm table
                          -m prints slabinfo
                          -S unit size
                          delay is the delay between updates in seconds. 
                          unit size k:1000 K:1024 m:1000000 M:1048576 (default is K)
                          count is the number of updates.

            vmstat從/proc/stat獲得數據

            輸出的含義如下: 
            FIELD DESCRIPTION FOR VM MODE
               Procs
                   r: The number of processes waiting for run time.
                   b: The number of processes in uninterruptible sleep.

               Memory
                   swpd: the amount of virtual memory used.
                   free: the amount of idle memory.
                   buff: the amount of memory used as buffers.
                   cache: the amount of memory used as cache.
                   inact: the amount of inactive memory. (-a option)
                   active: the amount of active memory. (-a option)

               Swap
                   si: Amount of memory swapped in from disk (/s).
                   so: Amount of memory swapped to disk (/s).

               IO
                   bi: Blocks received from a block device (blocks/s).
                   bo: Blocks sent to a block device (blocks/s).

               System
                   in: The number of interrupts per second, including the clock.
                   cs: The number of context switches per second.

               CPU
                   These are percentages of total CPU time.
                   us: Time spent running non-kernel code. (user time, including nice time)
                   sy: Time spent running kernel code. (system time)
                   id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
                   wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero.
                   st: Time spent in involuntary wait. Prior to Linux 2.6.11, shown as zero.

            3:查看內存使用情況--free
            usage: free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c count] [-V]
              -b,-k,-m,-g show output in bytes, KB, MB, or GB
              -l show detailed low and high memory statistics
              -o use old format (no -/+buffers/cache line)
              -t display total for RAM + swap
              -s update every [delay] seconds
              -c update [count] times
              -V display version information and exit

            [root@Linux /tmp]# free

                        total     used        free       shared    buffers   cached
            Mem:       255268    238332      16936         0        85540   126384
            -/+ buffers/cache:   26408       228860 
            Swap:      265000      0         265000

            Mem:表示物理內存統計 
            -/+ buffers/cached:表示物理內存的緩存統計 
            Swap:表示硬盤上交換分區的使用情況,這里我們不去關心。
            系統的總物理內存:255268Kb(256M),但系統當前真正可用的內存b并不是第一行free 標記的 16936Kb,它僅代表未被分配的內存。

            第1行  Mem:
            total:表示物理內存總量。 
            used:表示總計分配給緩存(包含buffers 與cache )使用的數量,但其中可能部分緩存并未實際使用。 
            free:未被分配的內存。 
            shared:共享內存,一般系統不會用到,這里也不討論。 
            buffers:系統分配但未被使用的buffers 數量。 
            cached:系統分配但未被使用的cache 數量。buffer 與cache 的區別見后面。 
            total = used + free    
            第2行   -/+ buffers/cached:
            used:也就是第一行中的used - buffers-cached   也是實際使用的內存總量。 
            free:未被使用的buffers 與cache 和未被分配的內存之和,這就是系統當前實際可用內存。
            free 2= buffers1 + cached1 + free1   //free2為第二行、buffers1等為第一行

            buffer 與cache 的區別
            A buffer is something that has yet to be "written" to disk. 
            A cache is something that has been "read" from the disk and stored for later use
            第3行:
            對操作系統來講是Mem的參數.buffers/cached 都是屬于被使用,所以它認為free只有16936.
            對應用程序來講是(-/+ buffers/cach).buffers/cached 是等同可用的,因為buffer/cached是為了提高文件讀取的性能,當應用程序需在用到內存的時候,buffer/cached會很快地被回收。
            所以從應用程序的角度來說,可用內存=系統free memory+buffers+cached.

            swap
            swap就是LINUX下的虛擬內存分區,它的作用是在物理內存使用完之后,將磁盤空間(也就是SWAP分區)虛擬成內存來使用.

            4:查看網卡情況--sar
            詳細見man
            4.1:查看網卡流量:sar -n DEV delay count 
            服務器網卡最大能承受流量由網卡本身決定,分為10M、10/100自適應、100+以及1G網卡,一般普通服務器用的是百兆,也有用千兆的。

            輸出解釋:
            IFACE
                   Name of the network interface for which statistics are reported.

            rxpck/s
                   Total number of packets received per second.

            txpck/s
                   Total number of packets transmitted per second.

            rxbyt/s
                   Total number of bytes received per second.

            txbyt/s
                   Total number of bytes transmitted per second.

            rxcmp/s
                   Number of compressed packets received per second (for cslip etc.).

            txcmp/s
                   Number of compressed packets transmitted per second.

            rxmcst/s
                   Number of multicast packets received per second.

            4.2:查看網卡失敗情況:sar -n EDEV delay count 
            輸出解釋:
            IFACE
                   Name of the network interface for which statistics are reported.

            rxerr/s
                   Total number of bad packets received per second.

            txerr/s
                   Total number of errors that happened per second while transmitting packets.

            coll/s
                   Number of collisions that happened per second while transmitting packets.

            rxdrop/s
                   Number of received packets dropped per second because of a lack of space in linux buffers.

            txdrop/s
                   Number of transmitted packets dropped per second because of a lack of space in linux buffers.

            txcarr/s
                   Number of carrier-errors that happened per second while transmitting packets.

            rxfram/s
                   Number of frame alignment errors that happened per second on received packets.

            rxfifo/s
                   Number of FIFO overrun errors that happened per second on received packets.

            txfifo/s
                   Number of FIFO overrun errors that happened per second on transmitted packets.


            5:定位問題進程--top, ps
            top -d delay,詳細見man
            ps aux 查看進程詳細信息
            ps axf 查看進程樹

            6:查看某個進程與文件關系--losf
            需要root權限才能看到全部,否則只能看到登錄用戶權限范圍內的內容

            lsof -p 77//查看進程號為77的進程打開了哪些文件
            lsof -d 4//顯示使用fd為4的進程 
            lsof abc.txt//顯示開啟文件abc.txt的進程
            lsof -i :22//顯示使用22端口的進程
            lsof -i tcp//顯示使用tcp協議的進程
            lsof -i tcp:22//顯示使用tcp協議的22端口的進程
            lsof +d /tmp//顯示目錄/tmp下被進程打開的文件
            lsof +D /tmp//同上,但是會搜索目錄下的目錄,時間較長
            lsof -u username//顯示所屬user進程打開的文件

            7:查看程序運行情況--strace
            usage: strace [-dffhiqrtttTvVxx] [-a column] [-e expr] ... [-o file]
                          [-p pid] ... [-s strsize] [-u username] [-E var=val] ...
                          [command [arg ...]]
               or: strace -c [-e expr] ... [-O overhead] [-S sortby] [-E var=val] ...
                          [command [arg ...]]

            常用選項:
            -f:除了跟蹤當前進程外,還跟蹤其子進程。
            -c:統計每一系統調用的所執行的時間,次數和出錯的次數等. 
            -o file:將輸出信息寫到文件file中,而不是顯示到標準錯誤輸出(stderr)。
            -p pid:綁定到一個由pid對應的正在運行的進程。此參數常用來調試后臺進程。

            8:查看磁盤使用情況--df
            test@wolf:~$ df
            Filesystem           1K-blocks      Used Available Use% Mounted on
            /dev/sda1              3945128   1810428   1934292  49% /
            udev                    745568        80    745488   1% /dev
            /dev/sda3             12649960   1169412  10837948  10% /usr/local
            /dev/sda4             63991676  23179912  37561180  39% /data

            9:查看網絡連接情況--netstat
            常用:netstat -lpn
            選項說明:
             -p, --programs           display PID/Program name for sockets
             -l, --listening          display listening server sockets
             -n, --numeric            don't resolve names
             -a, --all, --listening   display all sockets (default: connected)
            posted on 2010-11-21 12:25 閱讀(1357) 評論(1)  編輯 收藏 引用

            FeedBack:
            # re: [轉] linux 常用定位問題命令總結 2011-08-19 10:14 白癜風癥狀
            不錯  回復  更多評論
              
            久久精品人人做人人爽97 | 少妇被又大又粗又爽毛片久久黑人 | 国产V综合V亚洲欧美久久| 久久久老熟女一区二区三区| 777米奇久久最新地址| 久久九色综合九色99伊人| 亚洲国产精品久久久天堂| 久久精品嫩草影院| 色99久久久久高潮综合影院| 久久久国产精品亚洲一区| 欧美激情精品久久久久久| 99久久er这里只有精品18| 色播久久人人爽人人爽人人片aV| 天堂久久天堂AV色综合 | 奇米影视7777久久精品人人爽| 久久人人爽人人爽人人AV| 伊人久久大香线蕉精品不卡| 久久久久中文字幕| 久久久久亚洲AV成人片| 久久久精品国产| 久久99精品国产麻豆婷婷| 国产精品一久久香蕉国产线看| 一本色道久久88综合日韩精品| 99久久国产综合精品网成人影院| 久久久久亚洲AV成人片| 中文字幕乱码人妻无码久久| 午夜精品久久久久久影视777| 久久美女人爽女人爽| 久久久久久狠狠丁香| 久久久久久久综合日本亚洲| 777米奇久久最新地址| 日韩亚洲欧美久久久www综合网| 国产午夜福利精品久久2021| 久久午夜伦鲁片免费无码| 日韩精品久久无码中文字幕| 精品综合久久久久久97| 久久精品国产亚洲av麻豆图片 | 伊人久久大香线焦综合四虎| 国产人久久人人人人爽 | 97精品依人久久久大香线蕉97 | 波多野结衣久久精品|