Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

vmstat

vmstat is useful because it is installed on most linux based systems by default, doesn’t require root, and quickly shows you what is wrong… if you understand what is being said:

CPU slow1: r has numbers in it constantly, threads/tasks waiting to be processed by your gimp cpu CPU slow2: in is high, you are handling too many interrupts (likely from disk activity, but could be bad driver) Processes: us or sy is high? Some process is being a cpu hog, use top -n 1 to find it, and kill -9 the PID if needed Disk Subsystem Overloaded: wa is high? If you are waiting for IO then you need to upgrade your disk subsystem Not Enough RAM: si and so are high, swapping disk too much. You really shouldn’t swap at all for high performance. If these are high, in will be high too. Upgrade your RAM. Low Memory2: cs is high? The kernel is paging memory in and out of context. Likely you need more RAM, but it could be other issues too such as damaged hardware or pitiful software. Out of Memory: I ignore free, inact, active because it’s not as useful and understanding the actual reasons. Ie: if you are out of memory, you’ll know that, but unless you look at cs, so, si, etc you won’t know why. So it’s redundant.

vmstat 1 5

timstamp vmstat

[Expert@firewall]# vmstat 1 |awk '{now=strftime("%Y-%m-%d %T "); print now $0}'
2010-04-23 09:59:53 procs                      memory      swap          io     system         cpu
2010-04-23 09:59:53  r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy wa id
2010-04-23 09:59:53  1  0      0 2750344 101940 773080    0    0     0     1    1     1  0  0  0  0
2010-04-23 09:59:54  0  0      0 2750344 101940 773080    0    0     0    68 3930    64  0  0  0 100
2010-04-23 09:59:55  0  0      0 2750344 101940 773080    0    0     0     0 4354    37  0  0  0 100

Meaning (important)

CPU slow1:

r has numbers in it constantly, threads/tasks waiting to be processed by your gimp cpu

CPU slow2:

in is high, you are handling too many interrupts (likely from disk activity, but could be bad driver)

Processes:

us or sy is high? Some process is being a cpu hog, use top -n 1 to find it, and kill -9 the PID if needed

Disk Subsystem Overloaded:

wa is high? If you are waiting for IO then you need to upgrade your disk subsystem

Not Enough RAM:

si and so are high, swapping disk too much. You really shouldn’t swap at all for high performance. If these are high, in will be high too. Upgrade your RAM.

Low Memory2:

cs is high? The kernel is paging memory in and out of context. Likely you need more RAM, but it could be other issues too such as damaged hardware or pitiful software.

Out of Memory:

I ignore free, inact, active because it’s not as useful and understanding the actual reasons. Ie: if you are out of memory, you’ll know that, but unless you look at cs, so, si, etc you won’t know why. So it’s redundant.

Meaning (extras)

The ‘procs’ field has 2 columns:

r – The number of processes waiting for run time. b – The number of processes in uninterruptible sleep (blocked processes).

The ‘memory’ field has 4 columns: (see with vmstat -a)

swpd – The amount of used swap space(virtual memory) used. free – The amount of idle memory(free RAM). inact – The amount of inactive memory. active – The amount of active memory.

The ‘swap’ field has 2 columns:

si – Amount of memory swapped in from disk (/s). so – Amount of memory swapped to disk (/s).

The ‘io’ field has 2 columns:

bi – Blocks received from a block device (blocks in). bo – Blocks sent to a block device (blocks out).

The ‘system’ field has 2 columns:

in – The number of interrupts per second, including the clock (System interrupts). cs – The number of context switches per second (Process context switches).

The ‘cpu’ field has only 4 columns:

us: Time spent running non-kernel code. (user time, including nice time). sy: Time spent running kernel code. (system time). id: Time spent idle. wa: Time spent waiting for IO.