Generate System Resources Statistics in Ubuntu using ‘dstat’

‘dstat’ is a very handy tool that generates system resources statistics of your computer. Like most other these type of tools, ‘dstat’ is also based on the command-line. But because it uses vivid colors and separate columns (shown in the below screenshot), the output is easily readable and is very user-friendly too.

It is intended for individuals like systems administrators thus by default it includes few columns that are not really needed for most users. But by using few command-line arguments we can easily make it to only include system resources details that have a particular importance to you anyway.

And when combined with the Battery, CPU, Memory and currently running processes (and more), it behaves almost alike the previously reviewed ‘powerstat’ tool and can be used to monitor the power consumption of your Laptop as well.

It has a big number of features and I’m not going to write about them all as you can learn about them using its manual, but to mention some of its main features:

*. Monitors the CPU with details such as the user/system/idle/hardware and software interrupts.

*. CPU fan speed (might not work on certain computers).

*. Thermal readings (again, only works on certain PCs).

*. Outputs memory related data (used, buffers, cache, free and the Swap).

*. Disk read and write details.

*. Network activities (download/upload speeds, network packet count etc).

*. Shows the processes that use the CPU most (‘top processes’).

*. Monitors the battery (current percentage, remaining time, including the power consumption -- only when running on battery).

*. Supports a Black & White output.

It has tons of other features and some are only useful for monitoring server loads (such as MySQL: connection stats, I/O stats, hits and misses etc. Others such as NFS server operations and many more are also included). You can make ‘dstat’ to show only ‘top’ statistics of some of these above mentioned system resources as well.

If interested enter the below command in Ubuntu 12.10 Qquantal Quetzal, 12.04 Precise Pangolin, 11.10, 11.04, 10.10 and 10.04 to install ‘dstat‘.

sudo apt-get install dstat

As mentioned earlier, if the default output contains data that you don’t actually need, then you can use command-line arguments for adding and removing them. For that please refer to its manual by using the below command.

man dstat

Few tips …

I will write about few mostly commonly used command-line arguments, hoping that it will be useful for someone who is new and got a bit scared by having a look at its manual ;-).

Let’s say that you wanted a list of processes that use most of your CPU, their memory usage and the total power consumption of your computer. Then make sure you are running on battery and simply enter the below command.

dstat --top-cpu-adv --top-mem --power

It should give an output similar to the below one.

If you want the same details but including two additional ones, the disk read/write and network statistics, then use the below one.

dstat --top-cpu-adv --top-mem --power -n -d

When adding additional fields, make sure to resize the Terminal window as needed otherwise some details will be hidden.

To run it in its default mode, simply enter the below command.

dstat

You can press ‘Ctrl’ + ‘c’ keys to quit the application. That’s it, good luck.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: