If you have a Linux server running at your office or at a data center for which you are responsible, you want to maintain an uptime of as close to a hundred percent.如果您有一个Linux服务器运行在您的办公室或在数据中心,您有责任,要保持正常运行时间接近百分之百。 In such a case you want to make sure you keep an eye on how the system is running.在这种情况下要确保您留意系统如何运行。 To be precise you want to monitor all the system resources that contribute to the system running fine which then results in a high uptime.要准确要监控所有的系统资源,有助于该系统运行良好的结果,然后在一个高的正常运行时间。 Memory, CPU, disk usage… are some of the things you want to observe.内存,处理器,磁盘使用...有一些事情要观察。 We would usually use a combination of the tools that come with a Linux or UNIX installation, such as “free”, “top”, “vmstat”… I’ll introduce you to a tool that gives you just about all the info that the other tools combined give you, all under one roof - Dstat.我们通常会结合使用的工具,来了一个Linux或UNIX安装,如“自由” , “顶级” , “ vmstat ” ...我会向您介绍一个工具,让您刚才所有的信息说,其他工具结合起来给你,所有的同一个屋檐下-D stat。 The developer of this command line tool, Dag Wieers, calls it “a versatile replacement for vmstat, iostat, netstat and ifstat”.开发商的这一命令行工具,达格哈马Wieers ,将其称为“多面手更换vmstat , iostat , netstat和ifstat ” 。 He adds that “Dstat overcomes some of their limitations and adds some extra features…” To me Dstat is the mother of all command line system monitoring tools.他补充说, “ Dstat克服了它们的某些限制,并增加了一些额外的功能... ”对我来说Dstat是母亲的所有命令行系统监测工具。 It’s simple to install, easy to use, can be tweaked with ease, and it generates reports that you can plot as a graph to impress your boss.它安装简单,易于使用,可以轻松地调整,并生成报告,可以作为一个阴谋图你的老板留下深刻的印象。
Installing Dstat安装Dstat
Start by downloading the Dstat installer.开始下载Dstat安装。 Point your web browser to the Dstat project’s homepage -点你的网络浏览器的Dstat项目的主页- http://dag.wieers.com/home-made/dstat/ . 。 Scroll down to the section of the page where the downloads are listed.向下滚动到部分的网页下载列。 Pick the flavor of Linux on which you want to install the application and click on the download link.挑选风味的Linux要安装的应用,并点击下载链接。 Now download the latest version of Dstat for the version of the Linux distribution you are running.现在下载最新版本的Dstat的版本的Linux分布您正在运行。 I’ll show you how to do it for a Red Hat Enterprise Linux version 4 machine:我会告诉您如何做到这一点的红帽企业Linux第4版机:
# wget http://dag.wieers.com/rpm/packages/dstat/dstat-0.6.6-1.el4.rf.noarch.rpm # wget http://dag.wieers.com/rpm/packages/dstat/dstat-0.6.6-1.el4.rf.noarch.rpm
Now install Dstat:现在安装Dstat :
# rpm -Uvh dstat-0.6.6-1.el4.rf.noarch.rpm #更高Uvh dstat - 0.6.6 - 1.el4.rf.noarch.rpm
If the installation went though without errors, that’s it, you have Dstat installed and ready for use.如果安装了但没有错误,就是这样,你Dstat安装好且可以使用。 If there were some dependencies that came up during the installation just install the required packages and try again.如果有一些相依来到了在安装过程中只安装所需的软件包,然后再试一次。 I don’t think that Dstat has too many dependencies, so you should not face any problems.我不认为Dstat有太多依赖,所以你不应该遇到任何问题。
Using Dstat使用Dstat
With Dstat installed on your system you should be good to go.随着Dstat安装在您的系统你要善于去。 Begin by launching the command from a terminal:首先启动的命令从一个终端:
# dstat # dstat
The output would be something like the following.输出将类似于以下。 Hit the key combination of ctrl+c to exit.命中关键结合按Ctrl + C退出。
# dstat # dstat
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– -总的C PU使用率- -d isk/total-n et/total-,传呼,系统
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_系统语言遭围hiq siq | _read写| _recv _send | __in_ _out_ | _int_ _csw_
7 1 91 1 0 0| 0 0 | 0 0 | 0 0 | 0 0 7条1 91 1 0 0 | 0 0 | 0 0 | 0 0 | 0 0
1 0 99 0 0 0| 0 0 | 0 0 | 0 0 |1051 1945 1 0 99 0 0 0 | 0 0 | 0 0 | 0 0 | 1051年1945年
0 0 100 0 0 0| 0 12k|2269B 11.2k| 0 0 |1031 1923 0 0 100 0 0 0 | 0 12,000 | 2269B 11.2k | 0 0 | 1031年1923年
1 0 99 0 0 0| 0 40k| 0 0 | 0 0 |1078 2235 1 0 99 0 0 0 | 0 40K的| 0 0 | 0 0 | 1078 2235
0 0 100 0 0 0| 0 16k|6027B 21.5k| 0 0 |1008 2219 0 0 100 0 0 0 | 0最大16K | 6027B 21.5k | 0 0 | 1008年2219年
There are a number of options available for Dstat.有一些可供选择Dstat 。 As I mentioned earlier Dstat is quite easy to tweak.正如我前面提到Dstat很容易调整。 So if you want to limit the data reading to the CPU, disk, and network, run the following command:所以,如果你想限制数据读的CPU ,硬盘和网络,运行下面的命令:
# dstat -CDN # dstat -原价
-disk/total -net/total- —paging– —system– -disk/total -net/total- ,传呼,系统
_read write|_recv _send|__in_ _out_|_int_ _csw_ _read写| _recv _send | __in_ _out_ | _int_ _csw_
0 0 | 0 0 | 0 0 | 0 0 0 0 | 0 0 | 0 0 | 0 0
0 12k|2295B 9603B| 0 0 |1053 1957 0 12,000 | 2295B 9603B | 0 0 | 1053年1957年
0 0 | 594B 0 | 0 0 |1002 1893 0 0 | 594B 0 | 0 0 | 1002年1893年
0 960k| 292B 3346B| 0 0 |1072 2012 0 960k | 292B 3346B | 0 0 | 1072年2012年
0 4096B| 64B 0 | 0 0 |1031 1939 0 4096B |个64 0 | 0 0 | 1031年1939年
You can find more options in the application’s help document which you can access by entering the following:您可以找到更多的选择的应用程序的帮助文件,您可以通过输入以下内容:
# dstat -h # dstat小时
Play with the options a little so you get comfortable with them.播放的选项一点,让您获得舒适与他们。 The default interval between data reads is two seconds.预设的间隔读取数据是2秒。 You can change that interval if you need to.你可以改变这一区间如果您需要。 To increase the interval to ten seconds enter the following:为了增加间隔十秒输入以下内容:
# dstat 10 # dstat 10个
Another useful feature is to get aggregated updates for each entry.另一个有用的功能就是要更新汇总每个条目。 So you can have Dstat give you an update every ten seconds in a new line, but as the data changes your line itself gets updated every second.所以,你可以有Dstat给你一个更新每10秒一个新行,但作为数据变化的路线本身更新一次获得第二。
You might optionally want Dstat to give you five updates with a frequency of three seconds.你可能会选择想要Dstat给你5个更新的频率3秒。 Here’s how you would go about doing that:以下是如何你会去这样做:
# dstat 3 5 # dstat 3月5日
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– -总的C PU使用率- -d isk/total-n et/total-,传呼,系统
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_系统语言遭围hiq siq | _read写| _recv _send | __in_ _out_ | _int_ _csw_
3 1 95 2 0 0| 0 0 | 0 0 | 0 0 | 0 0 1月3日95 2 0 0 | 0 0 | 0 0 | 0 0 | 0 0
2 11 87 1 0 0| 0 180k|2581B 3239B| 0 0 |1136 697 2月11日87 1 0 0 | 0 180,000 | 2581B 3239B | 0 0 | 1136 697
7 8 85 0 0 0| 0 0 | 115k 106k| 0 0 |1603 3985 7月8日85 0 0 0 | 0 0 | 115k 106k | 0 0 | 1603年3985
2 1 98 0 0 0| 0 0 |77.5k 170k| 0 0 |1744 3856 2月1日98 0 0 0 | 0 0 | 77.5k 82 | 0 0 | 1744 3856
1 0 100 0 0 0| 0 0 |3451B 9993B| 0 0 |1045 149 1 0 100 0 0 0 | 0 0 | 3451B 9993B | 0 0 | 10时45分149
2 1 94 4 0 0| 0 276k|20.4k 31.1k| 0 0 |1219 804 2月1日94 4 0 0 | 0 276k | 20.4k 31.1k | 0 0 | 1219 804
The feature that I find most useful is the output.这项功能,我认为最有用的是输出。 Dstat allows you to have the output of a session written into a comma separated file which can later be imported into a spreadsheet application such as Microsoft Excel and the data can be plotted into a graph. Dstat可以让你的输出写入会议逗号分隔文件,该文件可以在以后导入到电子表格应用程序,如Microsoft Excel中的数据可以绘制成图表。 Here is how it can be used.下面是它如何被使用。
# dstat –output /tmp/dstat_data.csv -CDN # dstat输出/ tmp的/ dstat_data.csv -原价
Let the above command run while you run your applications or do your testing on this machine.让执行上述命令时,运行您的应用程序或做您的测试本机上。 Hit the key combination of ctrl+c when you are done.命中关键结合按Ctrl + C当你做。 Open the file dstat_data.csv with a spreadsheet application such as Microsoft Excel or Open Office.打开文件dstat_data.csv与试算表应用程式如Microsoft Excel或开放式办公。 You can then select the columns you want plotted into a graph and let your spreadsheet application do the magic.然后,您可以选择您想要栏绘制成图表,让您的电子表格应用程序做的魔力。
Get a Report by Mail收到邮件的报告
There may be cases wherein you want to observe how your server is performing over a period of time.有可能出现这样的情况,其中你想观察一下您的服务器正在执行一段时间。 You can setup a background process in Linux that will give you a reading with a certain interval, generate a report, and mail out the file to you.您可以设置一个后台进程在Linux中,将让您阅读具有一定的间隔,产生了一份报告,并邮寄出的档案给你。 This can be especially useful during a stress-test.这可能是特别有用在应力测试。 Here’s how you could do that.以下是你可以做到这一点。 The following script will run Dstat for three hours, reading the data every 30 seconds, and will mail out the report to me@myemailid.com.下面的脚本将运行Dstat了三个小时,阅读的数据,每30秒,并将邮件的报告me@myemailid.com 。
#!/bin/bash # ! /斌/庆祝
dstat –output /tmp/dstat_data_mail.csv -CDN 30 360 dstat输出/ tmp的/ dstat_data_mail.csv - 30原价360
mutt -a /tmp/dstat_data_mail.csv -s “Dstat Report for 3 hour run” me@myemailid.com < /dev/null傻子一个/ tmp的/ dstat_data_mail.csv比较“ Dstat报告3小时运行” me@myemailid.com “的/ dev /无效
Save the above script in a file called dstat_script.sh on your server, give it executable permission and then run it as a background process:除上述脚本在一个名为dstat_script.sh在您的服务器上,给它可执行权限,然后运行它作为背景的过程:
# chmod +x dstat_script.sh #属性+ x的dstat_script.sh
# nohup ./dstat_script.sh & # nohup 。 / dstat_script.sh &
Done.做完。 Yes, it’s that simple.是啊,这么简单。 You will now be mailed this report after it’s done running.现在,您将寄出这份报告后的工作运行。 You can optionally schedule this script as a daily cron job so that you can receive this data every day.您可以选择这个剧本的时间表作为日常作业,让您可以收到这个数据每天都在。
As you may already have realized Dstat is a wonderful tool when applied to performance monitoring and debugging.正如你可能已经意识到Dstat是一种非常棒的工具,当适用于执行情况的监测和调试。 The granularity, frequency, and nature of the data collected are completely up to you.粒度,频率和性质,所收集的数据是完全取决于您。 Dstat empowers you to know what is going on on your server. Dstat赋予你知道是怎么回事在您的服务器上。 Used wisely this power can result in a lot less sleepless nights for you.明智地使用这种权力会导致少很多不眠之夜你。






















{ 0 comments… ( 0评论... add one now现在添加一个 } )
Leave a Comment发表您的评论