4个LINUX性能监测工具

On 2010年08月13日, in linux, by netoearth

Most Linux users are familiar with the top command. Top shows you a list of processes on your system and provides a ton of useful information such as their CPU usage and owner. Unfortunately, this isn’t always enough data and many people don’t know where to turn next. This article covers three performance monitoring applications that show information top doesn’t tell you, and can greatly help in troubleshooting bottlenecks or just finding out more about your system. These utilities are iftop, iotop, and pv.

  1. iftop
  2. As you might be able to deduce from the name, iftop is a top-like application for network interfaces. You need to be root to run it, and it can be installed using the command:

    Ubuntu: sudo apt-get install iftop
    Fedora: sudo yum install iftop

    Run it in a terminal by specificying the interface you want to use, and optionally a -B (make sure you use a capital B) to display values in bytes rather than bits:

    # iftop -i eth3 -B

    The result is a screen showing you all the current connections on that port, as well as the throughput for each connection. Like top, iftop is full of features; press the h key to get an online help showing the options.

    Here you can see my network throughput as I run a speed test on dslreports.com. You’ll notice that there are separate indicators for incoming and outgoing traffic, and that three values are given on the right-hand side; these are the 2, 10, and 40 second averages.

    If you find iftop useful, you might want to read more about monitoring network traffic.

  3. iotop
  4. While iftop is great for monitoring network throughput, iotop is the utility you want if you need to measure disk access. It’s easily installable from the commandline:

    Ubuntu: sudo apt-get install iotop
    Fedora: sudo yum install iotop

    And you can run it with a simple sudo iotop command. What you’ll get is a listing of processes, like in top, but with their disk access information:

    In the above screenshot, I’m running a simple dd test to write to my local hard disk, which you can see as the first item in the window.

    iotop will tell you how much data each process is reading and writing, as well as if a process is using swap (which can be really helpful if you need to determine which process is thrashing your disk).

  5. pv
  6. The pv command isn’t a top-like application at all, but I’ve found it incredibly useful and I wanted to share it with you here. The pv utility is used between pipes on a command line and measures the speed of data throwing through that pipe. For example, here I am using pv to measure how quickly data is flowing between two dd commands:

    Installing pv is a simple one-liner:

    Ubuntu: sudo apt-get install pv
    Fedora: sudo yum install pv

    This is a great way to see how quickly one command is passing data to another command, when neither command is giving any output to report on its progress. If you’ve ever setup a pipe on the command line and wondered if it was actually doing anything, pv is the command you’ve been looking for. You can use it not only when you need to know the speed of data moving through a pipe, but whether there is any data moving at all.

  7. latencytop
  8. I wanted to give a quick mention to latencytop since I’m sure someone will ask about it if I don’t mention it. latencytop is a tool that shows you what resources a given process (or processes) are waiting for on your system. For example, it can tell you that a program is waiting on disk I/O or waiting to get a file lock. latencytop is a great tool, but on the whole it’s more useful for developers than end-users. If you’re interested, this is what it looks like:

    And this is how to install it:

    Ubuntu: sudo apt-get install latencytop
    Fedora: sudo yum install latencytop

Comments are closed.