Friday, January 9, 2009

Monitoring System Resources - Linux/Unix

What to monitor ?.

Some general performance expectations on any system.

Run Queues – A run queue should have no more than 1-3 threads queued per processor. For
example, a dual processor system should not have more than 6 threads in the run queue.
CPU Utilization – If a CPU is fully utilized, then the following balance of utilization should
be achieved.
Context Switches – The amount of context switches is directly relevant to CPU utilization.

1) vmstat
vmstat is a real-time performance monitoring tool. The vmstat command provides data that can be used to help find unusual system activity, such as high page faults or excessive context switches, and CPU usage.
Watch out for the main section
The cpu section reports the percentage of total CPU time in terms of user (us), system (sy), true idleness (id), and waiting for I/O completion (wa).

vmstat can be used to help find unusual system activity, such as high page faults or excessive context switches, that can lead to a degradation in system performance.You can monitor bi and bo for the transfer rate, and in for the interrupt rate. You can monitor swpd, si, and so to see whether the system is swapping.

2) Ps Command
To find out how the memory is used within a particular process, use ps for an overview of memory used per process:$ ps aux
The output of the ps aux command shows the total percentage of system memory that each process consumes, as well as its virtual memory footprint (VSZ) and the amount of physical memory that the process is currently using (RSS).

The RSS column provides the "resident set size" of a process; this is the amount of physical memory used by the process and a good indication of how much real memory a given process is using. The VSZ column details the total amount of memory being used by a process, including what is allocated for internal storage, but often swapped to disk. Both of these columns are common to the majority of ps variants.

3) IOSTAT

Iostat stands for input output statistics and it provides data about the input output devices such as disk, terminals, serial devices, and CPU, but we will use it here for disk-related data only.
By default, iostat generates two reports, one for CPU utilization and one for device utilization. You can use the –c option to get just the CPU report or the –d option to get just the device report
Syntax
The basic syntax is:
iostat -d -x interval count
-d : Display the device utilization report (d == disk)
-x : Display extended statistics including disk utilization
Option -- This may differ among operating system.
Interval -- Time period in seconds between two samples. iostat 5 will give data at each 5 seconds interval.
Count -- Number of times the data is needed. iostat 5 4 will give data at 5 seconds interval 4 times. If no count is specified, the samples continue indefinitely and must be terminated by pressing ^c. Commonly, the command is run without count, and samples are observed to get a feel of system state.

The values to look from the iostat output are:
The average service time (svctm)
Percentage of CPU time during which I/O requests were issued (%util)
See if a hard disk reports consistently high reads/writes (r/s and w/s)

Eg: iostat –d -x 1

4) NETSTAT

It also provides information about network routes and cumulative statistics for network interfaces, including the number of incoming and outgoing packets and the number of packet collisions.

netstat

No comments:

Post a Comment