歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> Linux服務器性能數據收集 - Sysstat介紹

Linux服務器性能數據收集 - Sysstat介紹

日期:2017/3/6 14:28:42   编辑:關於Unix
Linux 中的top,free等命令不能完全滿足我們性能數據收集的要求,我們需要一個更加強大的工具來收集性能數據。經過考察和對比,發現Sysstat是一個非常強大的工具,因此下載了試了下,效果不錯。Sysstat是一個工具集,包括sar、pidstat、iostat、mpstat、sadf Linux中的top,free等命令不能完全滿足我們性能數據收集的要求,我們需要一個更加強大的工具來收集性能數據。經過考察和對比,發現Sysstat是一個非常強大的工具,因此下載了試了下,效果不錯。Sysstat是一個工具集,包括sar、pidstat、iostat、mpstat、sadf、sadc。其中sar是其中最強大,也是最能符合我們測試要求的工具,同時pidstat也是非常有用的東東,因此本文結合性能測試重點介紹這兩個工具。

Sysstat的安裝

從http://pagesperso-orange.fr/sebastien.godard/download.html下載最新版本,解壓,安裝


Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--> wget http://pagesperso-orange.fr/sebastien.godard/sysstat-8.1.2.tar.gz
tar zxvf sysstat-8.1.2.tar.gz
cd sysstat-8.1.2
./configure
make
su
<enter root password>
make install 監視某個進程 通過ps命令找到相應進程的PID:


Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->ps -e

使用pidstat命令監視進程,詳細用法見:http://pagesperso-orange.fr/sebastien.godard/man_pidstat.html


Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->pidstat 2 5
//每隔2秒,顯示5次,所有活動進程的CPU使用情況
pidstat -p 3132 2 5
//每隔2秒,顯示5次,PID為1643的進程的CPU使用情況顯示
pidstat -p 3132 2 5 -r
//每隔2秒,顯示5次,PID為1643的進程的內存使用情況顯示很可惜的是,pidstat命令沒有保存性能數據的功能。查看性能數據

在sysstat工具包中,sar是最強大的了,通過sar幾乎可以監視所有的性能數據,同時,sar還支持將性能數據保存起來。
sar詳細用法請見:http://pagesperso-orange.fr/sebastien.godard/man_sar.html

查看CPU使用情況


Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->sar 2 5
//每隔2秒,顯示5次,CPU使用的情況查看內存使用情況


Copyright © Linux教程網 All Rights Reserved