Official website for Linux User & Developer

Create a graph of your system’s performance

Posted by Gavin Thomas

Use Dstat and Gnuplot to monitor performance, then turn that information into neat-looking graphs that anyone, even your manager, can understand…

Dstat data collection
A quick word on the usage of Dstat before we move onto the part where we collect system performance data. Run the command ‘dstat -h’ to get a dump of all the options supported by Dstat. You can customise the data collected by Dstat using these options. So, for example, if you want to only get the information about the CPU and the memory, run the command ‘dstat -cm’, where ‘c’ stands for CPU and ‘m’ stands for memory. You can also customise the time interval and the number of readings that Dstat takes. So if you want to run the command we just ran with an interval of ten seconds and get five readings, you would modify the command to look something like ‘dstat -cm 10 5’.

Now that we have Dstat installed and working, we can begin collecting the system-monitoring data. We’ll use Dstat to collect the CPU, memory and network data. We will also have Dstat write the time alongside each entry. We will get Dstat to note readings taken every five seconds. So the command we will be using to collect system performance data will look something like: ‘dstat -tcmn’. To allow Gnuplot to take this data, we will need the data to be stored in a file. For that we will redirect the output from the ‘dstat’ command to a file. The command will then look like this: ‘dstat -tcmn > dstat.dat’. Run this command for a few minutes, hit the key combination Ctrl+C to exit the command, and open “dstat.dat” in your favourite text editor. You will see a list of numbers that looks something like this:

Dstat output saved in the file ‘dstat.dat’
Dstat output saved in the file ‘dstat.dat’

If you see an output like the one above then you are good to go. Now you can run the following command to collect the actual data: ‘dstat -tcmn 10 > dstat.dat’. Let this command run for some time, at least ten minutes. You will get an output that looks something like the following in the file ‘dstat.dat’:

Dstat taking readings with ten-second intervals
Dstat taking readings with ten-second intervals

If you look at the time stamp in the output, you will see that each reading was taken with a gap of ten seconds. If you are running the command from a remote shell, such as over an SSH connection, you should make the command run in the background using the ‘nohup’ command. This way the Dstat process will not die if your SSH session expires. The new command will look something like this:

# nohup dstat -tcmn 10 > dstat.dat &
[1] 27857

When you hit the Return key on your keyboard after entering the command, you will be presented with a number. This is the process ID for the background process. Take note of this number: you will need it when you want to stop Dstat from collecting more data. Once you are done collecting data, run the following command to stop Dstat:

# kill -9 27857
[1]+  Killed      nohup dstat -tcmn 10 > dstat.dat

Replace ‘27857’ with the process ID you noted down. You should receive an output saying that the Dstat process was killed.

Pages: 1 2 3 4
  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.

      Inspired by this article i tried to make a finer script on similar lines
      Have a look :


      Inspired by this article i have tried to make a single script, have a look here:

    • TheOldFellow

      Useful. Pity the editor changed all the ” into “ and ” so that the scripts don’t actually work. People who publish Linux articles should know about this.


    • LordDarcy

      Works great! … Did need to replace the double quotes in the three scripts on page 4 with single quotes, though.

    • LordDarcy

      Works great! … Did need to replace the double quotes in the three scripts on page 4 with single quotes, though, and vice versa on the grep line.

    • carl

      Good stuff. Thanks.

    • JohnP

      While understanding how this task can be performed is useful, perhaps installing a FOSS tool like SysUsage to create performance graphs would result in greater usability?

    • pincho valla

      Is another and interesting way to measure things about your server, like rrdtool do. Congratulations for the clear and easy to follow article!

    • Pingback: IT-Technik / IT-Sicherheit | - GNU/Linux, Open Source, Softwareentwicklung, Methodik und Vim.()

    • Pingback: IT-Technik / IT-Sicherheit – 2009-12-18 | - GNU/Linux, Open Source, Softwareentwicklung, Methodik und Vim.()

    • jk04

      Nice and practical article. Adding “set grid” to the scripts would make the graphs look nicer.

    • Mark Seger

      Good article – similar to collectl but different. dstat reminds me a lot of collectl which does similar kinds of output but also provides provided a lot more detail, at least from a cursory read of the dstat website.

      Collectl would refer to the dstat output as ‘brief’ mode – great for a high level view of what’s going on but then you can also choose ‘verbose’ mode which shows a lot more data elements for each type of component you’re looking at and far too much to fit on one line. Then there’s ‘detail’ format which breaks down the verbose data by individual CPU, network or disk.

      Collectl also handles InfiniBand and Lustre data, something critical to HPC environments which was the initial target market.

      The collectl-utils rpm provides a tool called colplot, which is basically a web-based front-end to gnuplot. It has intimate knowledge of the types of data collectl collects, so you click a few check boxes and next thing you know some pretty cool plots show up. and


    • Michenux


      A fast and good solution to generate graphs from dstat log files is Vmstax.
      No configuration, just upload your log file and retrieve the generated graphs as png.

      More information at :

      Best regards

    • Pingback: How can I record system resource utilization over time on Ubuntu?()

    • Vikas Kumar

      kSAR is also a neat and much easier alternative.


    • pharmacy technician training

      Hello my friend! I want to say that this post is amazing, nice written and include almost all vital infos.

      I’d like to see more posts like this .

    • Pingback: Good tools and approaches for diagnosing poor performance - Just just easy answers()

    • icebox

      On my system I get
      Could not find/open font when opening font “arial”, using internal non-scalable font

      If I switch to
      set terminal pngcairo

      I get rid of the issue (it uses the cairo backend which knows the system fonts as opposed to GD)

    • Pingback: Raspberry Pi Raspbian CPU Performance Graph | DL-UAT()

    • MarkC

      Very simple and useful for profiling a period of time on a given machine. Thanks for a very useful post :-)