生活随笔
收集整理的這篇文章主要介紹了
Linux系统检测工具
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
通過檢測系統(tǒng),可以獲取一些基準(zhǔn)數(shù)據(jù),進(jìn)行分析,根據(jù)不同的業(yè)務(wù)特點(diǎn)系統(tǒng)不同組件的壓力,可以有cpu密集型,內(nèi)存密集型,網(wǎng)絡(luò)吞吐密集性型,io密集型?一??系統(tǒng)檢測工具?Free,Top,ps,Vmstat,Sysstat?二?Free工具的使用:用來查看linux系統(tǒng)中內(nèi)存和緩存的狀態(tài)?[root@hky-linux1?~]#?free??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????275756?????208948??????66808??????????0??????16260?????125608?-/+?buffers/cache:??????67080?????208676?Swap:??????1028120??????????0????1028120?Total:物理內(nèi)存總數(shù)?Used:總計(jì)分配給緩存使用的數(shù)量,其中部分緩存可能未被實(shí)際使用?Free:未被分配的內(nèi)存數(shù)量,還有多少可用?Shared:多個(gè)進(jìn)程共享的內(nèi)存總額?Buffers?:是在內(nèi)存中準(zhǔn)備寫入磁盤的緩沖區(qū),實(shí)現(xiàn)一次性批量寫入,避免頻繁寫入?Cached:是從磁盤中讀取的內(nèi)容在內(nèi)存中的緩存,為后續(xù)讀取提供一種快速的訪問方式?Mem(第二行):針對os的,buffers和cached都是被使用的,所以tatal=used+free??????[root@hky-linux1?~]#?echo?$[208948+66808]?275756?-/+?buffers/cached:?-buffers/cached:被程序?qū)崒?shí)在在吃掉的內(nèi)存?+?buffers/cached:可以挪用的內(nèi)存?所以total=used3+free3?????[root@hky-linux1?~]#?echo?$[208676+67080]?275756?Used2=?buffers2+cached2+used3?[root@hky-linux1?~]#?echo?$[16260+125608+67080]?208948?Free3=buffers2+cached2+free2?[root@hky-linux1?~]#?echo?$[16260+125608+66808]?208676????不做清除操作:0????清除pagecache:1????清除dentires和inodes:2????清除dentires和inodes和pagecache:3?清除緩存操作方法?這里不得不介紹一下proc?Proc是一個(gè)虛擬文件系統(tǒng)是用戶和內(nèi)核之間實(shí)現(xiàn)通信的一種手段????“取值”不做清除操作:0????清除pagecache:1????清除dentires和inodes:2????清除dentires和inodes和pagecache:3、?Proc里的文件不能直接vi編輯,可以通過如下方法編輯?Echo?[0,1,2,3]?>/proc/sys/vm/drop_caches/?下面是我使用proc的實(shí)例?[root@hky?vm]#?free??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????255412?????143964?????111448????0????????684??????37396?-/+?buffers/cache:?????105884?????149528?Swap:??????1020116??????????0????1020116?echo?1?>?/proc/sys/vm/drop_caches?[root@hky?vm]#?free??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????255412?????142912?????112500????0????????204??????36788?-/+?buffers/cache:?????105920?????149492?Swap:??????1020116??????????0????1020116?Buffer明顯變小?echo?2?>?/proc/sys/vm/drop_caches?[root@hky?vm]#?free??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????255412?????143548?????111864??????0????????588??????37164?-/+?buffers/cache:?????105796?????149616?Swap:??????1020116??????????0????1020116?因?yàn)?不清除臟頁,所以buffer有所上升?echo?3?>?/proc/sys/vm/drop_caches?[root@hky?vm]#?free??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????255412?????142808?????112604??????????0????????132??????36768?-/+?buffers/cache:?????105908?????149504?Swap:??????1020116??????????0????1020116?看見沒3效果最好?注意:?在執(zhí)行清除緩存之前,必須手動執(zhí)行sync??????1?sync命令?運(yùn)行sync子進(jìn)程,將所有未寫的系統(tǒng)緩沖區(qū)寫入到磁盤中,包含已經(jīng)修改的inode,保證文件系統(tǒng)的完整性??????2?sysnc在修改drop_caches的值,可以清除磁盤緩存,釋放內(nèi)存,得出真實(shí)的磁盤io??????3?清除磁盤緩存的另外一種方法就是執(zhí)行sync后umount掉對應(yīng)的磁盤分區(qū)設(shè)備?[root@hky-linux1?~]#?free;sync;free??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????275756?????209728??????66028????0??????16928?????125616?-/+?buffers/cache:??????67184?????208572?Swap:??????1028120??????????0????1028120??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????275756?????209756??????66000???0??????16936?????125608?-/+?buffers/cache:??????67212?????208544?Swap:??????1028120??????????0????1028120??[root@hky-linux1?~]#?echo?"3"?>?/proc/sys/vm/drop_caches?[root@hky-linux1?~]#?free??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????275756??????83112?????192644????0????????200??????19680?-/+?buffers/cache:??????63232?????212524?Swap:??????1028120??????????0????1028120?新命令:Last?|?more???//查看都有哪些用戶登錄?Top??–d??1??–n??1?>?file?Strings?file?舉例看看緩存的作用?[root@hky?vm]#?time?find?/?>/dev/null?real????2m9.407s?user????0m0.231s?sys?????0m7.445s?用時(shí)2分鐘多?Free?[root@hky?vm]#?free??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????255412?????231016??????24396?????0??????77620??????37452?-/+?buffers/cache:?????115944?????139468?Swap:??????1020116??????????0????1020116?Cached變的很大?現(xiàn)在重復(fù)執(zhí)行?[root@hky?vm]#?time?find?/?>/dev/null?real????0m2.538s?user????0m0.445s?sys?????0m1.092s?用時(shí)兩秒;?echo?"3"?>?/proc/sys/vm/drop_caches?[root@hky?vm]#?free??????????????total???????used???????free?????shared????buffers?????cached?Mem:????????255412?????144052?????111360??????????0????????188??????36800?-/+?buffers/cache:?????107064?????148348??Swap:??????1020116??????????0????1020116??[root@hky?vm]#?time?find?/?>/dev/null?real????1m29.158s?user????0m0.195s?sys?????0m5.109s???Free命令有用的參數(shù):?????引用?????·-b,-k,-m和-g分別按照bytes,?kilobytes,?megabytes,?gigabytes顯示結(jié)果。?????·-l區(qū)別顯示low和high內(nèi)存?????·-s?每隔若干秒刷新一次??三?Vmstat?vmstat命令是顯示Linux性能指標(biāo)的方法,輸出分為6個(gè)類別:進(jìn)程、內(nèi)存、交換區(qū)、I/O、系統(tǒng)和CPU?[root@hky-linux1?~]#?vmstat?進(jìn)程????????內(nèi)存?????????交換分區(qū)??io?????系統(tǒng)??????cpu?procs???r??b???swpd???free???buff??cache???si???so????bi????bo???in???cs???us??sy?id???wa?st??0??0????0????190212?872??21760????0????0????42???14??1043??106??1??1??97??1??0?進(jìn)程:?r列是可運(yùn)行進(jìn)程的數(shù)量,長期大于1,cpu不足,當(dāng)業(yè)務(wù)繁忙時(shí),不超過兩倍的cpu數(shù)量,也算正常,r越大,系統(tǒng)越繁忙?b列是阻塞進(jìn)程的數(shù)量:正常小為0?內(nèi)存:Swpd:已用的交換空間數(shù)量?Free:尚未分配的內(nèi)存?Buff:緩沖使用的內(nèi)存,對塊設(shè)備讀寫才需要緩沖?Cache:文件系統(tǒng)緩存使用的,?Swap:si和so為0是正常的?Si:從交換區(qū)到內(nèi)存的數(shù)量?So:從內(nèi)存到交換區(qū)的數(shù)量?I/O?Bi:從磁盤讀去的塊數(shù),數(shù)量越大,表示讀取的越頻繁?Bo:每秒寫入到磁盤的塊數(shù)。數(shù)量越大,磁盤活動率越高?System?In:系統(tǒng)中斷?Cs:進(jìn)程上下文開關(guān)?Cpu?Us:用戶進(jìn)程消耗—值比較高,則用戶進(jìn)程消耗cpu時(shí)間太長,長期大于50%,考慮優(yōu)化用戶程序,持續(xù)大于50,業(yè)務(wù)高峰期算是正常?Sy:內(nèi)核進(jìn)程消耗—us+sy大于80%,則cpu不足?Wa:I/O進(jìn)程消耗的cpu,超過30%,可能由磁盤大量隨即訪問造成?Id:空閑,持續(xù)小于50,服務(wù)高峰期可以接受?[root@hky-linux1?~]#?vmstat?2?5????//每兩秒查看一次,查看五次?procs???r??b???swpd???free???buff??cache???si???so????bi????bo???in???cs?us?sy?id?wa?st??0??0??????0?127740??21412??54752????0????0????42????13?1041??105??0??1?97??1??0??0??0??????0?127500??21412??54752????0????0?????0?????0?1015??105??1??3?96??0??0??0??0??????0?127500??21412??54752????0????0?????0?????0?1015???93??0??0?100??0??0??0??0??????0?127560??21420??54752????0????0?????0????34?1015???94??0??1?99??0??0??0??0??????0?127560??21420??54752????0????0?????0?????0?1014???93??0??1?99??0??0?現(xiàn)在測試一下查看5次,每次2秒用多少時(shí)間?[root@hky?~]#?time?vmstat?2?5?procs???r??b???swpd???free???buff??cache???si???so????bi????bo???in???cs?us?sy?id?wa?st??0??0????116??18784??32052??88552????0????0????49????20??710??119??2??4?91??3??0??0??0????116??18784??32052??88552????0????0?????0?????0??609???62??0??1?99??0??0??0??0????116??18784??32052??88552????0????0?????0????44??627???71??0??0?100??0??0??0??0????116??18784??32068??88552????0????0?????0????24??624???79??0??1?97??2??0??0??0????116??18784??32068??88552????0????0?????0?????0??614???71??0??0?100??0??0???real????0m8.016s?user????0m0.002s?sys?????0m0.003s?用時(shí)8秒,因?yàn)榈谝淮尾灰獣r(shí)間?這里有一個(gè)時(shí)間函數(shù)需要掌握?[root@hky?~]#?ceshi=$(date?+%s.%N);vmstat?2?3;hky=$(date?+%s.%N);?awk?-v?ceshi=${ceshi}?-v?hky=${hky}?'BEGIN?{print?hky-ceshi}'?procs???r??b???swpd???free???buff??cache???si???so????bi????bo???in???cs?us?sy?id?wa?st??0??0????116??14580??34872??89084????0????0????46????19??706??117??1??4?92??3??0??0??0????116??14580??34880??89076????0????0?????0????18??596???76??0??1?99??0??0??0??0????116??14580??34880??89088????0????0?????0?????0??589???67??0??0?100??0??0?4.01254?大家自己理解?Vmstat-a??看出內(nèi)存使用的和未使用的?[root@hky?~]#?vmstat?-a?procs???r??b???swpd???free??inact?active???si???so????bi????bo???in???cs?us?sy?id?wa?st??0??0????116??14400??70408?143008????0????0????46????19??706??117??1??4?92??3??0?Vmstat?–d?:?硬盤讀寫情況?[root@hky?~]#?vmstat?-d?disk-?????????total?merged?sectors??????ms??total?merged?sectors??????ms????cur????sec?ram0???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram1???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram2???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram3???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram4???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram5???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram6???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram7???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram8???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram9???????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram10??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram11??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram12??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram13??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram14??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?ram15??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?sda????90558??27351?1569858??606361??25774??55985??653314??776684??????0????512?sdb??????115????464????2272?????229?????30?????20?????100?????299??????0??????0?hdc??????701?????10????2920?????310??????0??????0???????0???????0??????0??????0?fd0????????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?disk-?????????total?merged?sectors??????ms??total?merged?sectors??????ms????cur????sec?md0????????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?loop0??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?loop1??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?loop2??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?loop3??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?loop4??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?loop5??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?loop6??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?loop7??????0??????0???????0???????0??????0??????0???????0???????0??????0??????0?Vmstat?–p?/dev/sdb2??1?某一塊盤的讀寫情況?四?Sysstay工具??Iostat?/sar?/mpstat?三個(gè)工具都來自Sysstay包?安裝sysstat很簡單??[root@hky-linux1?sysstat]#?rpm?-ivh?sysstat-9.0.6.1-3.i386.rpm?Sar收集器?/var/log/sa?修改配置文件?[root@hky-linux1?~]#?vi?/etc/cron.d/sysstat?#?Run?system?activity?accounting?tool?every?10?minutes?*/10?*?*?*?*?root?/usr/lib/sa/sa1?-S?DISK?10??60?#?0?*?*?*?*?root?/usr/lib/sa/sa1?-S?DISK?600?6?&?#?Generate?a?daily?summary?of?process?accounting?at?23:53?59?23?*?*?*?root?/usr/lib/sa/sa2?–A?[root@hky-linux1?~]#?vi?/etc/sysconfig/sysstat?#?sysstat-9.0.6.1?configuration?file.?#?How?long?to?keep?log?files?(in?days).?#?If?value?is?greater?than?28,?then?log?files?are?kept?in?#?multiple?directories,?one?for?each?month.?HISTORY=7000?#?Compress?(using?gzip?or?bzip2)?sa?and?sar?files?older?than?(in?days):?COMPRESSAFTER=3?統(tǒng)計(jì)cpu信息?[root@hky-linux1?~]#?sar?-u?Linux?2.6.18-53.el5?(hky-linux1)????????07/01/2010??????_i686_??(1?CPU)?06:30:02?AM?????CPU?????%user?????%nice???%system???%iowait????%steal?????%idle?06:40:01?AM?????all??????0.04??????0.00??????0.48??????0.13??????0.00?????99.35?06:50:01?AM?????all??????0.05??????0.00??????0.50??????0.15??????0.00?????99.30?07:00:01?AM?????all??????0.05??????0.00??????0.60??????0.46??????0.00?????98.90?07:10:01?AM?????all??????0.09??????0.00??????0.65??????0.51??????0.00?????98.76?07:20:01?AM?????all??????0.04??????0.20??????1.59??????4.55??????0.00?????93.63?07:30:01?AM?????all??????0.06??????0.00??????0.57??????0.28??????0.00?????99.08?Average:????????all??????0.05??????0.03??????0.73??????1.01??????0.00?????98.17?Cpu?All:?表示統(tǒng)計(jì)信息為所有?CPU?的平均值?%user:用戶運(yùn)行進(jìn)程所花的時(shí)間?%nice:運(yùn)行正常進(jìn)程所花的時(shí)間?%system:在內(nèi)核模式中運(yùn)行進(jìn)程所花的時(shí)間?%iowait:沒有進(jìn)程在該CPU上執(zhí)行時(shí),處理器等待I/O完成的時(shí)間?%steal?管理程序(hypervisor)為另一個(gè)虛擬進(jìn)程提供服務(wù)而等待虛擬?CPU?的百分比?%idle:沒有進(jìn)程在該CPU上執(zhí)行的時(shí)間?查看報(bào)告?[root@hky-linux1?sa]#?sar?-f?/var/log/sa/sa01?Linux?2.6.18-53.el5?(hky-linux1)????????07/01/2010??????_i686_??(1?CPU)?06:30:02?AM?????CPU?????%user?????%nice???%system???%iowait????%steal?????%idle?06:40:01?AM?????all??????0.04??????0.00??????0.48??????0.13??????0.00?????99.35?06:50:01?AM?????all??????0.05??????0.00??????0.50??????0.15??????0.00?????99.30?07:00:01?AM?????all??????0.05??????0.00??????0.60??????0.46??????0.00?????98.90?在多cpu的系統(tǒng)中,查看分解的cpu信息?[root@hky-linux1?sa]#?sar?-u?-P?ALL?5?5?Linux?2.6.18-53.el5?(hky-linux1)????????07/01/2010??????_i686_??(1?CPU)?07:38:51?AM?????CPU?????%user?????%nice???%system???%iowait????%steal?????%idle?07:38:56?AM?????all??????0.00??????0.00??????0.80??????0.00??????0.00?????99.20?07:38:56?AM???????0??????0.00??????0.00??????0.80??????0.00??????0.00?????99.20?磁盤io數(shù)據(jù)統(tǒng)計(jì)?[root@hky-linux1?~]#?sar?-d?5?2?Linux?2.6.18-53.el5?(hky-linux1)????????07/01/2010??????_i686_??(1?CPU)?07:40:36?AM???????DEV???????tps??rd_sec/s??wr_sec/s??avgrq-sz??avgqu-sz?????await?????svctm?????%util?07:40:41?AM????dev8-0??????0.00??????0.00??????0.00??????0.00??????0.01??????0.00??????0.00??????0.54?07:40:41?AM???dev8-16??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00?07:40:41?AM???dev8-32??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00???DEV:磁盤設(shè)備?Tps:每秒傳輸數(shù)?rd_sec/s:每秒xx字節(jié)讀取數(shù)?wr_sec/s:每秒xx字節(jié)寫入數(shù)?顯示io和傳送速率的信息?[root@hky-linux1?~]#?sar?-b?5?3?Linux?2.6.18-53.el5?(hky-linux1)????????07/01/2010??????_i686_??(1?CPU)?07:53:25?AM???????tps??????rtps??????wtps???bread/s???bwrtn/s?07:53:30?AM??????0.00??????0.00??????0.00??????0.00??????0.00?07:53:35?AM??????1.00??????0.00??????1.00??????0.00?????25.60?07:53:40?AM??????0.00??????0.00??????0.00??????0.00??????0.00?Average:?????????0.33??????0.00??????0.33??????0.00??????8.54?tps?每秒鐘物理設(shè)備的?I/O?傳輸總量?rtps?每秒鐘從物理設(shè)備讀入的數(shù)據(jù)總量?wtps?每秒鐘向物理設(shè)備寫入的數(shù)據(jù)總量?bread/s?每秒鐘從物理設(shè)備讀入的數(shù)據(jù)量,單位為?塊/s?bwrtn/s?每秒鐘向物理設(shè)備寫入的數(shù)據(jù)量,單位為?塊/s?顯示內(nèi)存頁面統(tǒng)計(jì)?[root@hky-linux1?~]#?sar?-B?5?Linux?2.6.18-53.el5?(hky-linux1)????????07/01/2010??????_i686_??(1?CPU)?07:55:26?AM??pgpgin/s?pgpgout/s???fault/s??majflt/s??pgfree/s?pgscank/s?pgscand/s?pgsteal/s????%vmeff?07:55:31?AM??????0.00??????8.02?????15.83??????0.00?????15.63??????0.00??????0.00??????0.00??????0.00?07:55:36?AM??????0.00??????6.45?????11.69??????0.00?????25.20??????0.00??????0.00??????0.00??????0.00?pgpgin/s?每秒鐘從磁盤讀入的系統(tǒng)頁面的?KB?總數(shù)?pgpgout/s?每秒鐘向磁盤寫出的系統(tǒng)頁面的?KB?總數(shù)?fault/s?系統(tǒng)每秒產(chǎn)生的頁面失效(major?+?minor)數(shù)量?majflt/s?系統(tǒng)每秒產(chǎn)生的頁面失效(major)數(shù)量?每秒創(chuàng)建的進(jìn)程數(shù)的進(jìn)程統(tǒng)計(jì)?[root@hky-linux1?~]#?sar?-C?5?3?Linux?2.6.18-53.el5?(hky-linux1)????????07/01/2010??????_i686_??(1?CPU)?07:57:12?AM?????CPU?????%user?????%nice???%system???%iowait????%steal?????%idle?07:57:17?AM?????all??????0.21??????0.00??????2.06??????0.82??????0.00?????96.91?07:57:22?AM?????all??????0.00??????0.00??????0.60??????0.20??????0.00?????99.19?網(wǎng)絡(luò)信息統(tǒng)計(jì)?[root@hky-linux1?~]#?sar?-n?DEV?5?3?|grep?eth0?07:58:22?AM??????eth0??????0.40??????0.20??????0.02??????0.01??????0.00??????0.00??????0.00?07:58:27?AM??????eth0??????0.20??????0.20??????0.01??????0.04??????0.00??????0.00??????0.00?[root@hky-linux1?~]#?sar?-n?DEV?5?3?Linux?2.6.18-53.el5?(hky-linux1)????????07/01/2010??????_i686_??(1?CPU)?07:45:44?AM?????IFACE???rxpck/s???txpck/s????rxkB/s????txkB/s???rxcmp/s???txcmp/s??rxmcst/s?07:45:49?AM????????lo??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00?07:45:49?AM??????eth0??????0.20??????0.20??????0.01??????0.03??????0.00??????0.00??????0.00?07:45:49?AM??????sit0??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00?IFACE:LAN接口?rxpck/s:每秒鐘接收的數(shù)據(jù)包?txpck/s:每秒鐘發(fā)送的數(shù)據(jù)包?rxbyt/s:每秒鐘接收的字節(jié)數(shù)?txbyt/s:每秒鐘發(fā)送的字節(jié)數(shù)?rxcmp/s:每秒鐘接收的壓縮數(shù)據(jù)包?txcmp/s:每秒鐘發(fā)送的壓縮數(shù)據(jù)包?rxmcst/s:每秒鐘接收的多播數(shù)據(jù)包?網(wǎng)絡(luò)錯誤信息統(tǒng)計(jì)?[root@hky-linux1?~]#?sar?-n?EDEV?5?3?Linux?2.6.18-53.el5?(hky-linux1)????????07/01/2010??????_i686_??(1?CPU)?07:48:24?AM?????IFACE???rxerr/s???txerr/s????coll/s??rxdrop/s??txdrop/s??txcarr/s??rxfram/s??rxfifo/s??txfifo/?07:48:29?AM????????lo??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00?07:48:29?AM??????eth0??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00?07:48:29?AM??????sit0??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00?[root@hky-linux1?~]#?sar?-n?EDEV?5?|egrep?'eth0|IFACE'?07:59:16?AM?????IFACE???rxerr/s???txerr/s????coll/s??rxdrop/s??txdrop/s??txcarr/s??rxfram/s??rxfifo/s??txfifo/s?07:59:21?AM??????eth0??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00??????0.00?IFACE:LAN接口?rxerr/s:每秒鐘接收的壞數(shù)據(jù)包?txerr/s:每秒鐘發(fā)送的壞數(shù)據(jù)包?coll/s:每秒沖突數(shù)?rxdrop/s:因?yàn)榫彌_充滿,每秒鐘丟棄的已接收數(shù)據(jù)包數(shù)?txdrop/s:因?yàn)榫彌_充滿,每秒鐘丟棄的已發(fā)送數(shù)據(jù)包數(shù)?txcarr/s:發(fā)送數(shù)據(jù)包時(shí),每秒載波錯誤數(shù)?rxfram/s:每秒接收數(shù)據(jù)包的幀對齊錯誤數(shù)?rxfifo/s:接收的數(shù)據(jù)包每秒FIFO過速的錯誤數(shù)?txfifo/s:發(fā)送的數(shù)據(jù)包每秒FIFO過速的錯誤數(shù)??dstat工具,可以做更多的信息采集????安裝????[root@hky-linux1?Server]#?rpm?-ivh?dstat-0.6.6-3.el5_4.1.noarch.rpm?warning:?dstat-0.6.6-3.el5_4.1.noarch.rpm:?Header?V3?DSA?signature:?NOKEY,?key?ID?37017186?Preparing...????????????????###########################################?[100%]????1:dstat??????????????????###########################################?[100%]????執(zhí)行?dstat?命令,默認(rèn)情況它會收集-cpu-、-disk-、-net-、-paging-、-system-的數(shù)據(jù),一秒鐘收集一次???語法結(jié)構(gòu):dstat?[-afv]?[options..]?[delay?[count]]?Dstat??-c?檢測cpu的情況?[root@hky-linux1?~]#?dstat?-c??usr?sys?idl?wai?hiq?siq???2???4??90???4???0???0???0???0?100???0???0???0???0???0?100???0???0???0?Dstat??-d?檢測硬盤讀寫情況?[root@hky-linux1?~]#?dstat?-d?-dsk/total-??read??writ??212k???47k????0?????0????0?????0?0???????????184k?Dstat??-m檢測內(nèi)存使用情況?[root@hky-linux1?~]#?dstat?-m???used??buff??cach??free???69M???30M??120M???50M???69M???30M??120M???50M???69M???30M??120M???50M???69M???30M??120M???50M?Dstat??-n?檢測網(wǎng)絡(luò)使用狀況?[root@hky-linux1?~]#?dstat?-n?-net/total-??recv??send????0?????0???60B??138B???60B??154B?[root@hky-linux1?~]#?dstat?-N?eth0,total?Terminal?width?too?small,?trimming?output.??usr?sys?idl?wai?hiq?siq|?read??writ|?recv??send:?recv??send|??in???out?>???1???2??93???3???0???0|?140k???36k|???0?????0?:???0?????0?|???0?????0?>???0???0?100???0???0???0|???0?????0?|??60B??314B:??60B??314B|???0?????0?>???0???0??99???0???0???1|???0?????0?|??60B??314B:??60B??314B|???0?????0?>?[root@hky-linux1?~]#??dstat?-dnyc?-N?eth0?-C?total?-f?5?Terminal?width?too?small,?trimming?output.???read??writ:?read??writ:?read??writ:?read??writ|?recv??send|?int???csw?>??537B????0?:?116k???32k:1252B????0?:1354B????0?|???0?????0?|1017???112?>????0?????0?:???0?????0?:???0?????0?:???0?????0?|??60B??314B|1005????79?>?[root@hky-linux1?~]#??dstat?-M?time,cpu,net,disk,sys,load,proc,app?Terminal?width?too?small,?trimming?output.????date/time???|usr?sys?idl?wai?hiq?siq|?recv??send|?read??writ|?int???csw?>?04-07?01:03:00|??1???2??94???2???0???0|???0?????0?|?113k???31k|1016???111?>?04-07?01:03:01|??0???3??96???1???0???0|??60B??420B|???0?????0?|1008????94?>?04-07?01:03:02|??1???1??96???2???0???0|??60B??420B|???0???380k|1036????82?>?………………………..?[root@hky-linux1?~]#?man?dstat?Iptraf的使用:流量監(jiān)控工具?安裝?Yum?–y?install?iptraf?[root@hky-linux1?~]#?iptraf?-d?eth0??//檢測eth0?in和out的數(shù)據(jù)包?掌握tcpdump的使用?[root@hky-linux1?~]#?tcpdump?-nn?-vv?dst?net?192.168.1.0/24?and?not?port?22?[root@hky-linux1?~]#?tcpdump??-nn?-vv?-i?eth0?icmp?tcpdump:?listening?on?eth0,?link-type?EN10MB?(Ethernet),?capture?size?96?bytes?01:37:31.691978?IP?(tos?0x0,?ttl?128,?id?10925,?offset?0,?flags?[none],?proto:?ICMP?(1),?length:?60)?192.168.1.101?>?192.168.1.6:?ICMP?echo?request,?id?1,?seq?5338,?length?40?01:37:31.692256?IP?(tos?0x0,?ttl??64,?id?34721,?offset?0,?flags?[none],?proto:?ICMP?(1),?length:?60)?192.168.1.6?>?192.168.1.101:?ICMP?echo?reply,?id?1,?seq?5338,?length?40?Strace工具:跟蹤程式執(zhí)行時(shí)的系統(tǒng)調(diào)用和所接收的信號?[root@hky-linux1?~]#?man?strace?STRACE(1)????????????????????????????????????????????????????????????STRACE(1)?NAME????????strace?-?trace?system?calls?and?signals?SYNOPSIS????????strace??[??-dffhiqrtttTvxx??]?[?-acolumn?]?[?-eexpr?]?...??[?-ofile?]?[????????-ppid?]?...??[?-sstrsize?]?[?-uusername?]?[?-Evar=val?]?...??[?-Evar??]????????...??[?command?[?arg?...??]?]???????strace??-c??[?-eexpr?]?...??[?-Ooverhead?]?[?-Ssortby?]?[?command?[?arg????????...??]?]?參數(shù):?-c?統(tǒng)計(jì)每一系統(tǒng)調(diào)用的所執(zhí)行的時(shí)間,次數(shù)和出錯的次數(shù)等?[root@hky-linux1?~]#?strace?-c?pwd?/root?%?time?????seconds??usecs/call?????calls????errors?syscall???66.08????0.000596?????????596?????????1???????????execve??14.86????0.000134??????????17?????????8???????????mmap2???6.76????0.000061??????????20?????????3???????????brk???6.76????0.000061??????????31?????????2???????????fcntl64???5.54????0.000050??????????25?????????2???????????munmap???0.00????0.000000???????????0?????????1???????????read???0.00????0.000000???????????0?????????1???????????write???0.00????0.000000???????????0?????????3???????????open???0.00????0.000000???????????0?????????5???????????close???0.00????0.000000???????????0?????????1?????????1?access???0.00????0.000000???????????0?????????2???????????mprotect???0.00????0.000000???????????0?????????2???????????lstat64???0.00????0.000000???????????0?????????6???????????fstat64???0.00????0.000000???????????0?????????1???????????getdents64???0.00????0.000000???????????0?????????1???????????set_thread_area???0.00????0.000000???????????0?????????1???????????openat???0.00????0.000000???????????0?????????1???????????fstatat64??100.00????0.000902????????????????????41?????????1?total?-d?輸出strace關(guān)于標(biāo)準(zhǔn)錯誤的調(diào)試信息?-f?跟蹤由fork調(diào)用所產(chǎn)生的子進(jìn)程?-ff?如果提供-o?filename,則所有進(jìn)程的跟蹤結(jié)果輸出到相應(yīng)的filename.pid中,pid是各進(jìn)程的進(jìn)程號?-F?嘗試跟蹤vfork調(diào)用.在-f時(shí),vfork不被跟蹤?-h?輸出簡要的幫助信息?-i?輸出系統(tǒng)調(diào)用的入口指針?-q?禁止輸出關(guān)于脫離的消息?-r?打印出相對時(shí)間關(guān)于,,每一個(gè)系統(tǒng)調(diào)用?-t?在輸出中的每一行前加上時(shí)間信息?-tt?在輸出中的每一行前加上時(shí)間信息,微秒級?-ttt?微秒級輸出,以秒了表示時(shí)間?-T?顯示每一調(diào)用所耗的時(shí)?-v?輸出所有的系統(tǒng)調(diào)用.一些調(diào)用關(guān)于環(huán)境變量,狀態(tài),輸入輸出等調(diào)用由于使用頻繁,默認(rèn)不輸出?-V?輸出strace的版本信息?-x?以十六進(jìn)制形式輸出非標(biāo)準(zhǔn)字符串?-xx?所有字符串以十六進(jìn)制形式輸出?-a?column?五?制造系統(tǒng)壓力?[root@hky-linux1?~]#??S=1000;?echo?"scale=${S};?4*a(1)"?|?bc?-l?-q?Vmstat的一個(gè)腳本?[root@hky-linux1?~]#?vmstat?1?2?|?grep?-v?sw?|?awk?'{print?$0;?for?(i=1;i<=NF;i++){r[i]+=$i}}END?{for(i=1;i<=NF;i++){printf"%d",r[i]/NR;printf("\n")}}'? ?
轉(zhuǎn)載于:https://blog.51cto.com/lya041/685378
總結(jié)
以上是生活随笔為你收集整理的Linux系统检测工具的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。