There are many tools available that allow you to monitor your server which you install a package and it does allot for you. See different blog posts for a more full monitoring solution.

Vmstat is a free tool which reports information about processes, memory, paging, block IO, traps, and cpu activity.

VmStat is available on all major-like Unix operating systems by default.

Full details are available at: http://linuxcommand.org/man_pages/vmstat8.html


This will run vmstat every 10 seconds 2160 times.

vmstat 10 2160


Normally we would want to record this information, and maybe run it at a certain time every day so we can compare the results. Maybe you need to provide this information to a third party for some reason.

To do this you would want to setup a cron job to record this output to a file.

To do this following this example.

Create a new file called: vmstat_script.sh


# vmstat_script.sh
vmstat 10 2160 > /home/glyn/crons/myvmstatfile.dat
mv /home/glyn/crons/myvmstatfile.dat /home/glyn/crons/myvmstatfile.dat.`date +%Y-%m-%d`

So by running this file it will record the output of vmstat every 10 seconds for 6 hours. It will name the file the date that this was ran.

Next we setup our cronjob

crontab -e

Add the line:

0 6 * * * /home/glyn/crons/vmstat_script.sh >> /home/gr/crons/vmstat_error.txt

This will start the script at 6am every day

So you now will have a history of vmstat from 6am – noon every day


Looking at this information doesn’t really mean much unless you have allot of free time to look through it all or use OpenOffice calc to create a graph.

Turning this information into graphs makes spotting issues a whole lots easier.

One option is using Gnuplot.

sudo apt-get install gnuplot

Now you can use gnuplot to generate your graph

set term pngcairo 
set output 'output.png' 
plot 'vmstat.txt' using 13 title 'CPU user load' with lines, 'vmstat.txt' using 14 title 'CPU system load' with lines, 'vmstat.txt' using 15 title 'CPU idle time' with lines, 'vmstat.txt' using 16 title 'CPU IO wait time' with lines

My output when I ran “stress” during vmstat


Another nice tool is https://github.com/joewalnes/web-vmstats to view the graphs as the data is generated (Requires websocketd and SmoothieCharts).


Leave a Reply

Your email address will not be published. Required fields are marked *