Create a graph of your system’s performance
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:
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’:
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.













Inspired by this article i tried to make a finer script on similar lines
Have a look : http://h3manth.com/content/plotting-performance-graph-gnulinux-box
Inspired by this article i have tried to make a single script, have a look here:
http://h3manth.com/content/plotting-performance-graph-gnulinux-box
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.
R.
Works great! … Did need to replace the double quotes in the three scripts on page 4 with single quotes, though.
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.
Good stuff. Thanks.
While understanding how this task can be performed is useful, perhaps installing a FOSS tool like SysUsage http://freshmeat.net/projects/sysusage/ to create performance graphs would result in greater usability?
Is another and interesting way to measure things about your server, like rrdtool do. Congratulations for the clear and easy to follow article!
[...] Create a graph of your system’s performance [...]
[...] Create a graph of your system’s performance [...]
Nice and practical article. Adding “set grid” to the scripts would make the graphs look nicer.
What's your opinion?