Monday, December 28, 2009

SAR Command in hp-ux

The sar utility is short for System Activity Reporter. This system activity reporter is quite popular in HP/UX systems, and is now becoming available for AIX and Solaris dialects of UNIX. SAR has much of the same functionality as the vmstat utility, but provides additional details.

There are four main ways to invoke sar, each producing a different output display as shown in Table 2-5.

sar command arguments UNIX display output
sar –b Monitor UNIX buffer activity
sar –u Monitor CPU usage
sar –w RAM memory switching and swapping activity
sar –d Monitor disk usage

Note: Each dislect of UNIX has different display formats for the sar utility. For example, some of the argument flags in the Solaris are not available on HP/UX. Please check your UNIX-specific documentation for details on your UNIX server.
The output from sar reports usually shows a time-based snapshot of activity. This is true for all reports that you'll see in this section. When you issue the sar command, you pass two numeric arguments. The first represents the time interval between samples, and the second represents the number of samples to take.

For example:
sar –u 10 5

The sar command in this example is requesting five samples taken at 10-second intervals.

sar –u: The CPU Report

The sar –u command is very useful for seeing the overall CPU consumption over time. In the example that follows, I execute sar –u to see the state of the CPU. CPU time can be allocated into the following four sections: user mode, system mode, waiting on I/O, and idle.

root> sar -u 2 5
HP-UX corp-hp1 B.11.00 U 9000/800 12/25/00
07:18:44 %usr %sys %wio %idle
07:18:46 0 0 1 99
07:18:48 0 0 1 99
07:18:50 4 0 13 83
07:18:52 2 1 7 90
07:18:54 0 0 3 98
Average 1 0 5 93

sar –w: The Memory Switching and Swapping Activity Report
The sar –w command is especially useful if you suspect that your database server is experiencing a memory shortage. The following example shows the swapping activity report that you get from sar:

root> sar -w 5 5
HP-UX corp-hp1 B.11.00 U 9000/800 12/25/00
07:19:33 swpin/s bswin/s swpot/s bswot/s pswch/s
07:19:38 0.00 0.0 0.00 0.0 261
07:19:43 0.00 0.0 0.00 0.0 231
07:19:48 0.00 0.0 0.00 0.0 326
07:19:53 0.00 0.0 0.00 0.0 403
07:19:58 0.00 0.0 0.00 0.0 264
Average 0.00 0.0 0.00 0.0 297

The column descriptions for sar –w are as follows:
* swpin/s?Number of process swap-ins per second.
* swpot/s?Number of process swap-outs per second.
* bswin/s?Number of 512-byte swap-ins per second.
* bswot/s?Number of 512-byte swap-outs per second.
* pswch/s?Number of process context switches per second.

sar –b: The Buffer Activity Report

The sar -b command causes sar to report buffer activity, which equates to disk I/O activity and is especially useful if you suspect that your database is I/O bound. The report shows real disk I/O, and the interaction with the UNIX Journal File System (JFS) buffer. For example, below we see a sample of sar output over a 5-second interval:

>sar -b 1 5

HP-UX corp-hp1 B.11.00 U 9000/800 12/25/00
07:20:40 bread/s lread/s %rcache bwrit/s lwrit/s %wcache pread/s pwrit/s
07:20:41 0 72 100 6 7 14 0 0
07:20:42 0 3 100 3 3 0 0 0
07:20:43 0 3 100 0 9 100 0 0
07:20:44 0 26 100 6 12 50 0 0
07:20:45 0 19 100 3 15 80 0 0
Average 0 25 100 4 9 61 0 0

In the output shown here, you see the following data columns:

* Bread/s Number of physical reads from disk per second.
* lread/s?Number of reads per second from the UNIX JFS buffer cache.
* %rcache?Buffer cache hit ratio (for the UNIX JFS buffer cache) for read requests.
* bwrit/s?Number of physical writes to disk per second. This gives the DBA an indication of the overall write activity on the server.
* lwrit/s?Number of writes per second to the UNIX JFS buffer cache.
* %wcache?Buffer cache hit ratio (for the UNIX JFS buffer cache) for write requests.
* pread/s?Number of reads per second from disk. This is an excellent measure of the load on the I/O subsystem.
* pwrit/s?Number of writes per second to disk

The sar –b command is often used in reactive tuning when you want to correlate what is happening inside Oracle with what is happening on the database server. Now let’s turn our attention to the UNIX sadc utility

No comments:

Post a Comment