HP-UX has a number of tools that are bundled with the operating system. Additional sophisticated tools can be purchased separately. The bundled tools usually work in text mode. Some of these utilities are listed here.
The iostat command is used to monitor I/O activity for disk drives .
The vmstat command is used to monitor activity of virtual memory.
The netstat and lanadmin commands are used to monitor network activity such as incoming and outgoing network traffic, use of protocols, IP addresses assigned to interface adapters, etc.
The top utility is used to monitor processes that are utilizing more CPU time. Processes are listed in a sorted form. Percentage of CPU idle time is also displayed. This utility also shows some information about real and virtual memory.
The System Activity Reporter ( sar ) shows a number of kernel parameters and CPU utilization.
Other than these utilities, you may also use GlancePlus, which is an additional software application. It has both text and graphic interfaces. This tool provides comprehensive system information. It can be used to collect information including the following.
list of processes
CPU utilization
memory utilization
network utilization
disk utilization
swap space utilization
GlancePlus plots graphical representation of the data collected in real time so that you may have an overview of the running system. It will be discussed in more detail later in this chapter.
Virtual memory statistics are displayed using the vmstat command. It displays information about processes, page faults, memory, and CPU as shown here. (The output is formatted to fit onto the page.)
# vmstat -n VM memory page avm free re at pi po fr de sr 2275 44047 2 0 0 0 1 0 0 faults in sy cs 106 88 33 CPU cpu procs us sy id r b w 0 0 99 0 0 0 #
The -n option is used with the command to improve the format of the output.
The virtual memory ( VM ) part of the output is divided into three parts : memory , page , and faults . The explanation of fields under the memory subheading is as follows .
avm | Active virtual memory. These are the pages that have been assigned to some processes. |
free | Free pages. |
A number of columns are present under the page subheading.
re | Page reclaims. A large number shows a memory shortage. |
at | Address translation faults. |
pi | Pages paged in. |
po | Pages paged out. |
fr | Pages freed per second. |
de | Anticipated short term memory shortfall. |
sr | Pages scanned by clock algorithm, per second. |
The faults subheading shows trap and interrupt rate averages per second over the last 5 seconds.
in | Device interrupts per second. |
sy | System calls per second. |
cs | CPU context switch rate. |
The CPU part of the output has been divided into two subparts, cpu and procs . The columns under the cpu subheading show CPU utilization.
us | User time for normal and low-priority processes. |
sy | System time. |
id | CPU idle time. |
An explanation of the different fields under the procs subheading is as given here.
r | The process is in run queue. |
b | Number of processes blocked for some resource. |
w | It shows runable but swapped out from the main memory. |
More-detailed information can be displayed using this command using different options at the command line. See the manual pages for more details.
Performance of disk I/O is monitored using the iostat command. This command formats the data of each disk in four columns as shown next .
# iostat device bps sps msps c0t6d0 105 10.8 1.0 c0t5d0 0 0.0 1.0 #
An explanation of these columns is given here.
device | Shows the actual disk device for which the report is given. |
bps | Shows kilobytes transferred per second to/from the device. |
sps | Lists the number of seeks per second. |
msps | The time in milliseconds per average seek. |
If you have a number of disks installed, the command is very useful to determine if one of these disks is heavily used. In such a case, you may redistribute data on different disks such that every disk is sharing the system load. A number of factors may cause heavy utilization of only one disk. For example, you may have configured high-priority swap space on the same disk which is already loaded with a database.
By default, the iostat command displays its output once and then exits. If you want to display the disk statistics after every four seconds for five times, you can use the following command.
# iostat 4 5 device bps sps msps c0t6d0 105 10.8 1.0 c0t5d0 0 0.0 1.0 c0t6d0 21 3.0 1.0 c0t5d0 0 0.0 1.0 c0t6d0 31 5.8 1.0 c0t5d0 0 0.0 1.0 c0t6d0 12 2.0 1.0 c0t5d0 0 0.0 1.0 c0t6d0 8 3.0 1.0 c0t5d0 0 0.0 1.0 #
The first parameter shows the delay in seconds between executions, and the second parameter shows the number of times the statistics will be calculated. The above output shows that most of the load is on disk c0t6d0 .
The most widely used tool for system performance monitoring is top and it is available on almost all UNIX systems. It shows the top CPU utilization processes. When you start top , it displays a screen of information after every five seconds. A typical screen shown by top is like the one shown in Figure 25-1. In each screen, the topmost line shows the system name and the time at which the information was collected and displayed. Output of the top command is divided into three major parts. These three parts are CPU, memory, and processes. The CPU part shows the following information.
Load average in preceding 5 and 15 minutes. This information is useful to check any abrupt changes in the system load.
Number of processes currently active on the system.
Processes in each state. Figure 25-1 shows that out of 67 processes, 65 are in sleep state, and two are in running state.
Percentage of CPU time used in each CPU state. If your system has multiple CPUs, one line for every CPU will be present here. In Figure 25-1, 99.2% of CPU time is idle, showing that most of the time, the CPU is sitting idle. Any performance problem with this system is definitely not a CPU problem.
Next is the memory area, which shows the following information.
total physical memory installed
active physical memory
virtual memory
free virtual memory
total free memory
The process data consists of a number of columns. These columns are sorted depending on the CPU utilization in descending order. The process that is utilizing the CPU the most is listed at the top (the reason the command is named top ).
A brief explanation of the columns in the process area is given below.
CPU | This is the first column, which is not shown in Figure 25-1. It is present on systems with multiple CPUs. This represents a CPU number on which the process is being executed. |
TTY | The terminal used by the process. |
PID | Process ID. |
USERNAME | Name of the owner of the process. |
PRI | Process priority. |
NI | Nice value. |
SIZE | Total size of the process in memory. |
RES | Resident size of the process. This is an approximation . |
STATE | Current state of the process. |
TIME | CPU time consumed by the process. |
%WCPU | Weighted CPU percentage utilization by the process. |
%CPU | Raw CPU percentage utilization by the process. |
COMMAND | Name of the command that started the process. |
To display information after a specified time, use the -s option. The following command displays top information after every 7 seconds.
top s7
To quit using top , press the key. You can also use the -d option with a number and top will exit after showing that many number of screens.
This utility can be used to monitor system activity over a period of time. For example, to monitor system activity for 24 hours, you can start this command, and it can log the activity in a disk file. This disk file can be analyzed later at a convenient time. The following command stores system activity data in a file /home/root/sar.data 360 times, once every 10 seconds (total time one hour ).
sar -o /home/root/sar.data 10 360
This file can be analyzed later by using the following command.
sar -f /home/root/sar.data
A number of system parameters can be monitored using sar . Some of these are shown next.
The -u option of the sar command shows CPU statistics. The output shows a division of CPU time as user, system, waiting for I/O, and idle states. The following command shows CPU statistics five times, once each second.
# sar -u 1 5 HP-UX hp0 B.11.00 A 9000/839 11/29/99 12:27:53 %usr %sys %wio %idle 12:27:54 1 1 0 98 12:27:55 0 0 0 100 12:27:56 0 0 0 100 12:27:57 0 0 0 100 12:27:58 0 0 0 100 Average 0 0 0 100 #
Checking buffer cache activity is useful for database applications. Using the -b option with sar can do this.
# sar -b 1 5 HP-UX hp0 B.11.00 A 9000/839 11/29/99 12:28:52 bread/s lread/s %rcache bwrit/s lwrit/s %wcache pread/s pwrit/s 12:28:53 0 61 100 0 1 100 0 0 12:28:54 0 113 100 0 1 100 0 0 12:28:55 0 0 0 0 0 0 0 0 12:28:56 0 0 0 0 0 0 0 0 12:28:57 0 2 100 0 0 0 0 0 Average 0 35 100 0 0 100 0 0 #
The different fields in the output of the command are explained here.
bread/s | Number of read operations per second from disk to buffer cache. |
lread/s | Number of read operations per second from buffer cache. |
%rcache | Buffer cache hit ratio for read requests . |
bwrit/s | Number of write operation per seconds from buffer cache to disk. |
lwrit/s | Number of write operations per second to the buffer cache. |
%wcache | Buffer cache hit ratio for write requests. |
pread/s | Number of read operations per second from raw device. |
pwrit/s | Number of write operations per second to raw device. |
The sar utility can be used for other tasks as well. Options that can be used with sar are listed in Table 25-1.
Option | Meaning |
---|---|
-b | Monitor buffer cache |
-d | Monitor disk activity |
-q | Monitor queue length |
-u | Monitor CPU activity |
-w | Monitor swap space activity |
-o | Save data into a file |
-f | Read previously saved data from a file |
Top |