As some of you may know, I have recently switched from a shared hosting package to a dedicated server. This means that I have direct control of the whole computer that is hosting hansmast.com and the other websites that I am running. With shared hosting, you share the computer with a bunch of other people. With the dedicated server, I have been learning a lot of Linux. One thing that I have wanted to do is to check the server’s performance. I wanted to check the CPU usage and memory allocation. I didn’t know how. Until now.
There’s a simple command vmstat that produces a very useful, very cryptic output:
[root@u15183998 root]# vmstat 5 10 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 0 0 0 76576 13080 100752 0 0 16 33 1032 50 21 5 72 2 0 0 0 76584 13092 100740 0 0 0 19 1007 30 5 0 95 0 0 0 0 76440 13096 100736 0 0 0 15 1005 26 8 1 91 0 0 0 0 76432 13108 100724 0 0 2 14 1030 74 32 2 65 0 0 0 0 76448 13116 100716 0 0 0 8 1005 12 0 0 100 0 0 0 0 76448 13116 100716 0 0 0 18 1008 31 5 0 94 0 2 0 0 76296 13124 100776 0 0 0 54 1018 53 63 27 10 0 0 0 0 76400 13136 100764 0 0 0 47 1008 24 3 0 97 0 0 0 0 76400 13136 100764 0 0 0 0 1003 10 1 0 99 0 0 0 0 76464 13136 100764 0 0 0 8 1005 13 0 0 100 0
First, let me tell you how this command works. The first argument, 5 in this case, is the amount of seconds that the command collects data for each iteration. The second argument, 10 in this case, is the number of times the command is run. Running it multiple times (i.e. second argument) gives you a textual graph to look at.
Unless you are really deep into solving a really knotty problem, there are only a couple of columns that you need to pay attention to. The first and foremost is the “id” column under CPU. This displays the idle CPU percentage. The other columns under CPU break down the CPU usage into categories: us = userspace, sy = kernel, wa = I/O wait. The second column you will be most interested in is the “free” column under memory. This display the kBs of free memory. Don’t worry if this is low; to improve performance, Linux automatically caches frequently accessed hard disk files in the memory, so the memory will often be nearly full. The third column that will be of interest is the r column. This shows how many processes are waiting to be run.
If you want more information on what the rest of the columns mean, you can find that here.
Update: I found a much better way. Just type in “top”. It should be installed on most linux distros. It displays all sorts of much easier to read stats and they auto-update.



