dcsimg

Peeking In, At Linux

Last month's "Tech Support" showed how to monitor resource utilization with Cacti. This month, let's use vmstat to track down any bottlenecks that Cacti might have found. Part of the procps package (which contains many other useful utilities such as ps, top, w, and kill), vmstat reports statistical information about process status, memory consumption, paging activity, block I/O operations, interrupts, context switches, and processor usage. vmstat is available from http://procps.sourceforge.net and is licensed under the GPL. While you can download and install the latest version of procps, it's a standard set of utilities found in almost every Linux install.

Last month’s “Tech Support” showed how to monitor resource utilization with Cacti. This month, let’s use vmstat to track down any bottlenecks that Cacti might have found. Part of the procps package (which contains many other useful utilities such as ps, top, w, and kill), vmstat reports statistical information about process status, memory consumption, paging activity, block I/O operations, interrupts, context switches, and processor usage. vmstat is available from http://procps.sourceforge.net and is licensed under the GPL. While you can download and install the latest version of procps, it’s a standard set of utilities found in almost every Linux install.

A nice feature of vmstat is its overview of process, memory, swap, I/O, system, and CPU activity in just one line of numbers. Figure One shows a sample of vmstat output.




Figure One: Sample output of vmstat


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 104232 218884 3364308 0 0 0 1 1 1 4 1 0 1

Briefly, r and b are the number of processes waiting for run time and the number of processes in uninterruptible sleep, respectively. swpd, free, buff, and cache display how much virtual memory is being used (kB), the amount of idle memory (kB), the amount of memory used as buffers (kB), and the amount of memory used as a page cache, in that order. si shows the amount of memory swapped in from disk (kB/s), while so conveys the amount of memory swapped to disk (kB/s). bi and bo reflect the blocks sent to and from a block device (in blocks per second), respectively. in measures the number of interrupts per second, including the clock. cs shows the number of context switches per second. Finally, us, sy, id, and wa display the percentage of total processor time consumed by user-space, the kernel, spent idle, and spent in I/O wait, respectively.

vmstat can be invoked in a few different ways. Typing vmstat with no parameters yields a single line of output containing averages (calculated from the time the system was last booted). Given an optional delay, such as vmstat 5, vmstat prints a line with averages as above, and then prints a new line every 5 seconds until interrupted. Each line after the first represents the values for that time period. Lastly, you can specify a delay and a count value, as in vmstat 5 10, to print a report every 5 seconds terminating after 10 lines. Five seconds seems to be a good delay, as the output is based on a reasonable amount of data.

Fully interpreting vmstat output requires an in-depth understanding of Linux or Unix architecture, but you’ll quickly find it useful with a couple of tips and a little testing.

For example, if the r column is consistently higher than the number of CPUs in the machine, you are most likely CPU-bound and would benefit from more or faster processors. You can find out what’s eating your CPU time using a tool such as top. With similar reasoning, you can deduce whether your bottleneck is caused by memory or I/O and then use an appropriate tool to narrow down the problem or upgrade your hardware. Don’t forget that, regardless of how much memory you have, the free column eventually dwindles. This is normal and is a result of your memory being used for I/O cache and buffers — it is not necessarily indicative of a memory shortage.

Installing True Type Fonts

If you own a new flat-panel display, but your web pages and documents just don’t “look right,” perhaps you need to install True Type fonts. Many web pages and documents use True Type fonts, but by default, Linux doesn’t have any installed. Luckily, Xfree86 4.0 and above supports True Type fonts. (If you’re using an older version of X you can either upgrade, or install a font server such as xfsft.)

The first thing to do is find a copy of each of the fonts that you’d like to install. The easiest way to do this is to copy them from a Windows machine or from a CD-ROM. Some True Type fonts can even be downloaded from the Internet.

Once you’ve found some fonts, choose where to install them, such as /usr/share/fonts/truetype/. Then copy all of the .ttf files into the directory and run the following commands as root:


# cd /usr/share/fonts/truetype
# ttmkfdir > fonts.scale
# mkfontdir
# chkfontpath -a /usr/share/fonts/truetype
# fc-cache

Now, the True Type fonts in that directory are available to your applications.

The instructions above should work for most distros. Some distributions include configuration tools or tricks to make font installs even easier. Regardless of how you install them, True Type is sure to greatly improve your Linux experience. Enjoy.



Jeremy Garcia is the founder of LinuxQuestions.org, a free, friendly, and active Linux community. Please send questions and feedback to jeremy@linuxquestions.org.

Comments are closed.