TranslateProject/published/201406/Linux Terminal--Dstat monitoring tools.md
wxy a71aa7de9e renamed: 10 Database Tools For Linux Users To Use!.md -> 201406/10 Database Tools For Linux Users To Use!.md
renamed:    10 Linux Platforms Meant For Embedded Systems.md -> 201406/10 Linux Platforms Meant For Embedded Systems.md
	renamed:    20140527 4MLinux 9.0 Beta Is a 55 MB Operating System That Has It All.md -> 201406/20140527 4MLinux 9.0 Beta Is a 55 MB Operating System That Has It All.md
	renamed:    20140527 A Complete Historical Timeline of Linux Evolution.md -> 201406/20140527 A Complete Historical Timeline of Linux Evolution.md
	renamed:    20140528 Setup Backup Server Using Bacula And Webmin On Ubuntu 14.04.md -> 201406/20140528 Setup Backup Server Using Bacula And Webmin On Ubuntu 14.04.md
	renamed:    20140528 Why We Shouldn't Accept Bad Linux Ports.md -> 201406/20140528 Why We Shouldn't Accept Bad Linux Ports.md
	renamed:    20140529 Add Windows Like Bottom Taskbar In Ubuntu Unity 14.04.md -> 201406/20140529 Add Windows Like Bottom Taskbar In Ubuntu Unity 14.04.md
	renamed:    20140529 Command Line Tuesdays--The Introductory.md -> 201406/20140529 Command Line Tuesdays--The Introductory.md
	renamed:    20140529 How To Share Disks In VirtualBox Between Linux Guest OS.md -> 201406/20140529 How To Share Disks In VirtualBox Between Linux Guest OS.md
	renamed:    20140529 Install RainLoop Webmail (A Web Based Email Client) using 'Nginx and Apache' in Arch Linux.md -> 201406/20140529 Install RainLoop Webmail (A Web Based Email Client) using 'Nginx and Apache' in Arch Linux.md
	renamed:    20140529 What is a good terminal emulator on Linux.md -> 201406/20140529 What is a good terminal emulator on Linux.md
	renamed:    20140529 Why No Flash Support for Linux Is Good for Open Source.md -> 201406/20140529 Why No Flash Support for Linux Is Good for Open Source.md
	renamed:    20140530 Fix 'Cannot Add PPA' Error In Ubuntu 14.04 and Linux Mint.md -> 201406/20140530 Fix 'Cannot Add PPA' Error In Ubuntu 14.04 and Linux Mint.md
	renamed:    20140530 How To Install Linux On A MacBook Pro Retina.md -> 201406/20140530 How To Install Linux On A MacBook Pro Retina.md
	renamed:    20140530 Linux script command--A recorder inside your Terminal.md -> 201406/20140530 Linux script command--A recorder inside your Terminal.md
	renamed:    20140603 App Grid Is A Superior Ubuntu Software Center Alternative.md -> 201406/20140603 App Grid Is A Superior Ubuntu Software Center Alternative.md
	renamed:    20140603 Linux Foundation to donate portion of membership fees to Code.org.md -> 201406/20140603 Linux Foundation to donate portion of membership fees to Code.org.md
	renamed:    20140603 Write your first Linux Kernel module.md -> 201406/20140603 Write your first Linux Kernel module.md
	renamed:    20140604 Command line secrets.md -> 201406/20140604 Command line secrets.md
	renamed:    20140604 Setup Virtual Hosts In Apache On Ubuntu 14.04 LTS.md -> 201406/20140604 Setup Virtual Hosts In Apache On Ubuntu 14.04 LTS.md
	renamed:    20140607 Cup 2014 Brazil--Watch FIFA World Cup 2014 Competition in Your Linux Desktop.md -> 201406/20140607 Cup 2014 Brazil--Watch FIFA World Cup 2014 Competition in Your Linux Desktop.md
	renamed:    20140607 How To Extract Images From Videos Using ffmpeg.md -> 201406/20140607 How To Extract Images From Videos Using ffmpeg.md
	renamed:    20140607 How To Install iCup 2014 In Linux.md -> 201406/20140607 How To Install iCup 2014 In Linux.md
	renamed:    20140607 Linux--Bash Delete All Files In Directory Except Few.md -> 201406/20140607 Linux--Bash Delete All Files In Directory Except Few.md
	renamed:    20140607 New OpenSSL breach is no Heartbleed-but needs to be taken seriously.md -> 201406/20140607 New OpenSSL breach is no Heartbleed-but needs to be taken seriously.md
	renamed:    20140607 Nuvola Player 2.4.0 Released -- A Online Cloud Music Player for Linux.md -> 201406/20140607 Nuvola Player 2.4.0 Released -- A Online Cloud Music Player for Linux.md
	renamed:    20140607 Practical Interview Questions and Answers on Linux Shell Scripting.md -> 201406/20140607 Practical Interview Questions and Answers on Linux Shell Scripting.md
	renamed:    20140607 Steam Hits The Big 500 For Linux Games.md -> 201406/20140607 Steam Hits The Big 500 For Linux Games.md
	renamed:    20140607 Ubuntu One Formally Shuts Down.md -> 201406/20140607 Ubuntu One Formally Shuts Down.md
	renamed:    20140609 How To Know If Your System Has USB 3.0 Port In Linux [Quick Tip].md -> 201406/20140609 How To Know If Your System Has USB 3.0 Port In Linux [Quick Tip].md
	renamed:    20140609 Open Source LDAP Solutions.md -> 201406/20140609 Open Source LDAP Solutions.md
	renamed:    "20140609 OpenELEC 4.0.4 \347\216\260\345\267\262\345\217\221\345\270\203, \345\237\272\344\272\216 XBMC 13.1 \342\200\234Gotham\342\200\235.md" -> "201406/20140609 OpenELEC 4.0.4 \347\216\260\345\267\262\345\217\221\345\270\203, \345\237\272\344\272\216 XBMC 13.1 \342\200\234Gotham\342\200\235.md"
	renamed:    20140610 How to set up Internet connection sharing with iptables on Linux.md -> 201406/20140610 How to set up Internet connection sharing with iptables on Linux.md
	renamed:    20140610 IPFire 2.13 Core 78 Linux Firewall OS Receives OpenSSL Fixes.md -> 201406/20140610 IPFire 2.13 Core 78 Linux Firewall OS Receives OpenSSL Fixes.md
	renamed:    20140610 Open Source SDN Project OpenDaylight Adds New Members.md -> 201406/20140610 Open Source SDN Project OpenDaylight Adds New Members.md
	renamed:    20140610 Top 7 Desktop Environment For Linux.md -> 201406/20140610 Top 7 Desktop Environment For Linux.md
	renamed:    20140611 HTG Explains--What' s the Difference Between Linux and BSD.md -> 201406/20140611 HTG Explains--What' s the Difference Between Linux and BSD.md
	renamed:    20140611 How to Prevent Other Users From Accessing Your Home Directory in Ubuntu 14.04.md -> 201406/20140611 How to Prevent Other Users From Accessing Your Home Directory in Ubuntu 14.04.md
	renamed:    20140612 Command Line Tuesdays--Part One.md -> 201406/20140612 Command Line Tuesdays--Part One.md
	renamed:    20140612 Dpkg Vulnerabilities Closed in Ubuntu 14.04.md -> 201406/20140612 Dpkg Vulnerabilities Closed in Ubuntu 14.04.md
	renamed:    20140616 How To Install Numix Icon Theme In Fedora 20.md -> 201406/20140616 How To Install Numix Icon Theme In Fedora 20.md
	renamed:    20140616 Ubuntu Desktop Next 14.10 Images Available to Download.md -> 201406/20140616 Ubuntu Desktop Next 14.10 Images Available to Download.md
	renamed:    20140616 Ubuntu for Phones Activated on 10,000 Devices.md -> 201406/20140616 Ubuntu for Phones Activated on 10,000 Devices.md
	renamed:    20140617 14 Apps To Boost Ubuntu.md -> 201406/20140617 14 Apps To Boost Ubuntu.md
	renamed:    20140619 Improve Battery Life with Laptop Mode Tools 1.65.md -> 201406/20140619 Improve Battery Life with Laptop Mode Tools 1.65.md
	renamed:    20140619 Red Hat to Acquire eNovance, Focus Together on OpenStack.md -> 201406/20140619 Red Hat to Acquire eNovance, Focus Together on OpenStack.md
	renamed:    20140620 Celebrating 30 Years of X.md -> 201406/20140620 Celebrating 30 Years of X.md
	renamed:    20140620 ENCRYPT DNS TRAFFIC IN LINUX WITH DNSCRYPT (VIA OPENDNS).md -> 201406/20140620 ENCRYPT DNS TRAFFIC IN LINUX WITH DNSCRYPT (VIA OPENDNS).md
	renamed:    20140620 How to enable testing and unstable repository on Debian.md -> 201406/20140620 How to enable testing and unstable repository on Debian.md
	renamed:    20140625 Canonical Debuts 'Orange Box' for Ubuntu OpenStack Cloud Demos.md -> 201406/20140625 Canonical Debuts 'Orange Box' for Ubuntu OpenStack Cloud Demos.md
	renamed:    8 examples of findmnt command to check mounted file systems on Linux.md -> 201406/8 examples of findmnt command to check mounted file systems on Linux.md
	renamed:    Bash Getopts--Scripts with Command Line Options.md -> 201406/Bash Getopts--Scripts with Command Line Options.md
	renamed:    Collectl--An Advanced All-in-One Performance Monitoring Tool for Linux.md -> 201406/Collectl--An Advanced All-in-One Performance Monitoring Tool for Linux.md
	renamed:    Fix Adobe Flash Player Issue In Chromium In Ubuntu 14.04.md -> 201406/Fix Adobe Flash Player Issue In Chromium In Ubuntu 14.04.md
	renamed:    Guide To Install Ubuntu 14.04 In Dual Boot Mode With Windows 8 Or 8.1 UEFI.md -> 201406/Guide To Install Ubuntu 14.04 In Dual Boot Mode With Windows 8 Or 8.1 UEFI.md
	renamed:    How To Install 'California' Calendar App in Ubuntu 14.04.md -> 201406/How To Install 'California' Calendar App in Ubuntu 14.04.md
	renamed:    How To Remove Drive Icons From Unity Launcher In Ubuntu 14.04 [Beginner Tips].md -> 201406/How To Remove Drive Icons From Unity Launcher In Ubuntu 14.04 [Beginner Tips].md
	renamed:    How to Install Windows 8.1 and Ubuntu 14.04 LTS on the Same Computer.md -> 201406/How to Install Windows 8.1 and Ubuntu 14.04 LTS on the Same Computer.md
	renamed:    How to download webcomics from the command line on Linux.md -> 201406/How to download webcomics from the command line on Linux.md
	renamed:    How to launch applications differently with Gnome-Pie on Linux desktop.md -> 201406/How to launch applications differently with Gnome-Pie on Linux desktop.md
	renamed:    How to manage Linux containers with Docker on Ubuntu.md -> 201406/How to manage Linux containers with Docker on Ubuntu.md
	renamed:    How to manage ip addresses and subnets with phpIPAM.md -> 201406/How to manage ip addresses and subnets with phpIPAM.md
	renamed:    How to manage passwords from the command line on Linux.md -> 201406/How to manage passwords from the command line on Linux.md
	renamed:    How to monitor Nginx web server from the command line in real time.md -> 201406/How to monitor Nginx web server from the command line in real time.md
	renamed:    How to set up a web-based lightweight system monitor on Linux.md -> 201406/How to set up a web-based lightweight system monitor on Linux.md
	renamed:    How to take a screenshot from the command line on Linux.md -> 201406/How to take a screenshot from the command line on Linux.md
	renamed:    How to take full length screenshots of websites via terminal.md -> 201406/How to take full length screenshots of websites via terminal.md
	renamed:    How to use LVM in Linux.md -> 201406/How to use LVM in Linux.md
	renamed:    How to verify DDOS attack with netstat command on Linux Terminal.md -> 201406/How to verify DDOS attack with netstat command on Linux Terminal.md
	renamed:    Install SoundCloud In Ubuntu 14.04.md -> 201406/Install SoundCloud In Ubuntu 14.04.md
	renamed:    Linux Pros' Top Command Line Secrets.md -> 201406/Linux Pros' Top Command Line Secrets.md
	renamed:    Linux Terminal--Dstat monitoring tools.md -> 201406/Linux Terminal--Dstat monitoring tools.md
	renamed:    Making Linux Feel at Home.md -> 201406/Making Linux Feel at Home.md
	renamed:    Open Source's Cult Of Personality Is Dying--Thankfully.md -> 201406/Open Source's Cult Of Personality Is Dying--Thankfully.md
	renamed:    Pros' Secrets and Red Hat 7 and PCLinuxOS 2014.05 Reviews.md -> 201406/Pros' Secrets and Red Hat 7 and PCLinuxOS 2014.05 Reviews.md
	renamed:    Start Practising Linux ip command and Avoid the Habit of Using ifconfig.md -> 201406/Start Practising Linux ip command and Avoid the Habit of Using ifconfig.md
	renamed:    TechView--Linus Torvalds Inventor of Linux.md -> 201406/TechView--Linus Torvalds Inventor of Linux.md
	renamed:    Turn Off Bluetooth By Default In Ubuntu 14.04 [Quick Tip].md -> 201406/Turn Off Bluetooth By Default In Ubuntu 14.04 [Quick Tip].md
	renamed:    Ubuntu Linux Community Manager Jono Bacon Leaves Canonical.md -> 201406/Ubuntu Linux Community Manager Jono Bacon Leaves Canonical.md
	renamed:    What Heartbleed Teaches Us--Be An Open Source Contributor, Not Just A User.md -> 201406/What Heartbleed Teaches Us--Be An Open Source Contributor, Not Just A User.md
	renamed:    Why htop Command Compete Linux top Command.md -> 201406/Why htop Command Compete Linux top Command.md
2014-06-30 21:53:24 +08:00

6.3 KiB
Raw Permalink Blame History

Linux终端下 dstat 监控工具

dstat 是一个可以取代vmstatiostatnetstat和ifstat这些命令的多功能产品。dstat克服了这些命令的局限并增加了一些另外的功能增加了监控项也变得更灵活了。dstat可以很方便监控系统运行状况并用于基准测试和排除故障。

dstat可以让你实时地看到所有系统资源例如你能够通过统计IDE控制器当前状态来比较磁盘利用率或者直接通过网络带宽数值来比较磁盘的吞吐率在相同的时间间隔内

dstat将以列表的形式为你提供选项信息并清晰地告诉你是在何种幅度和单位显示输出。这样更好地避免了信息混乱和误报。更重要的是它可以让你更容易编写插件来收集你想要的数据信息以从未有过的方式进行扩展。

Dstat的默认输出是专门为人们实时查看而设计的不过你也可以将详细信息通过CSV输出到一个文件并导入到Gnumeric或者Excel生成表格中。

###特性###

  • 结合了vmstatiostatifstatnetstat以及更多的信息
  • 实时显示统计情况
  • 在分析和排障时可以通过启用监控项并排序
  • 模块化设计
  • 使用python编写的更方便扩展现有的工作任务
  • 容易扩展和添加你的计数器(请为此做出贡献)
  • 包含的许多扩展插件充分说明了增加新的监控项目是很方便的
  • 可以分组统计块设备/网络设备,并给出总数
  • 可以显示每台设备的当前状态
  • 极准确的时间精度,即便是系统负荷较高也不会延迟显示
  • 显示准确地单位和和限制转换误差范围
  • 用不同的颜色显示不同的单位
  • 显示中间结果延时小于1秒
  • 支持输出CSV格式报表并能导入到Gnumeric和Excel以生成图形

安装方法

Ubuntu/Mint和Debin系统

本地软件库中有相关安装包,你可以用下面命令安装:

# sudo apt-get install dstat

RHEL/Centos和Fedora系统:

你可以在romforge软件库中添加有相关安装包参照指导,使用如下命令很简单就能进行安装:

   # yum install dstat

ArchLinux系统

相关软件包在社区资源库中,你可以用这个命令来安装:

# pacman -S dstat

###使用方法 ###

dstat的基本用法就是输入dstat命令输出如下

这是默认输出显示的信息:

CPU状态CPU的使用率。这项报告更有趣的部分是显示了用户系统和空闲部分这更好地分析了CPU当前的使用状况。如果你看到"wait"一栏中CPU的状态是一个高使用率值那说明系统存在一些其它问题。当CPU的状态处在"waits"时那是因为它正在等待I/O设备例如内存磁盘或者网络的响应而且还没有收到。

磁盘统计:磁盘的读写操作,这一栏显示磁盘的读、写总数。

网络统计:网络设备发送和接受的数据,这一栏显示的网络收、发数据总数。

分页统计系统的分页活动。分页指的是一种内存管理技术用于查找系统场景一个较大的分页表明系统正在使用大量的交换空间或者说内存非常分散大多数情况下你都希望看到page in换入和page out换出的值是0 0。

系统统计这一项显示的是中断int和上下文切换csw。这项统计仅在有比较基线时才有意义。这一栏中较高的统计值通常表示大量的进程造成拥塞需要对CPU进行关注。你的服务器一般情况下都会运行运行一些程序所以这项总是显示一些数值。

默认情况下dstat每秒都会刷新数据。如果想退出dstat你可以按"CTRL-C"键。

需要注意的是报告的第一行,通常这里所有的统计都不显示数值的。

这是由于dstat会通过上一次的报告来给出一个总结所以第一次运行时是没有平均值和总值的相关数据。

但是dstat可以通过传递2个参数运行来控制报告间隔和报告数量。例如如果你想要dstat输出默认监控、报表输出的时间间隔为3秒钟,并且报表中输出10个结果你可以运行如下命令

dstat 3 10

在dstat命令中有很多参数可选你可以通过man dstat命令查看大多数常用的参数有这些

  • -l :显示负载统计量
  • -m 显示内存使用率包括usedbuffercachefree值
  • -r 显示I/O统计
  • -s :显示交换分区使用情况
  • -t :将当前时间显示在第一行
  • fs 显示文件系统统计数据包括文件总数量和inodes值
  • nocolor :不显示颜色(有时候有用)
  • socket :显示网络统计数据
  • tcp 显示常用的TCP统计
  • udp 显示监听的UDP接口及其当前用量的一些动态数据

当然不止这些用法dstat附带了一些插件很大程度地扩展了它的功能。你可以通过查看/usr/share/dstat目录来查看它们的一些使用方法常用的有这些

  • -disk-util :显示某一时间磁盘的忙碌状况
  • -freespace :显示当前磁盘空间使用率
  • -proc-count :显示正在运行的程序数量
  • -top-bio 指出块I/O最大的进程
  • -top-cpu 图形化显示CPU占用最大的进程
  • -top-io 显示正常I/O最大的进程
  • -top-mem :显示占用最多内存的进程

举一些例子:

查看全部内存都有谁在占用:

dstat -g -l -m -s --top-mem

显示一些关于CPU资源损耗的数据

dstat -c -y -l --proc-count --top-cpu

###如何输出一个csv文件###

想输出一个csv格式的文件用于以后可以通过下面的命令

# dstat output /tmp/sampleoutput.csv -cdn

via: http://linuxaria.com/howto/linux-terminal-dstat-monitoring-tools

译者:disylee 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出