tailieunhanh - Mastering Unix Shell Scripting p4

Phương pháp này hậu tố là linh hoạt nhất, nhưng nó cũng dễ bị sai lầm trong các tập tin ngoại lệ. Đối với những sai lầm, chúng ta cần phải kiểm tra các mục trong trường hợp ngoại lệ để thấy rằng họ phù hợp với tiêu chuẩn mà chúng tôi đã quyết định. | 190 Chapter 7 Solaris sar 10 4 SunOS wilma Generic i .86pc 07 29 02 23 01 55 usr sys wio idle 23 02 05 1 1 0 98 23 02 15 12 53 0 35 23 02 25 15 67 0 18 23 02 35 21 59 0 21 Average 12 45 0 43 Now let s look at the average of the samples directly. sar 10 4 grep Average Average 12 45 0 43 What Is the Common Denominator With the sar command the only common denominator is that we can always grep on the word Average. Like the iostat command the fields vary between some Unix flavors. We can use a similar case statement to extract the correct fields for each Unix flavor as shown in Listing . OS uname case OS in AIX HP-UX SunOS F1 2 F2 3 F3 4 F4 5 echo nThe Operating System is OS n Linux F1 3 F2 4 F3 5 F4 6 echo nThe Operating System is OS n echo nERROR OS is not a supported operating system n echo n . n exit 1 esac Listing Case statement for the sar fields of data. Monitoring System Load 191 Notice in Listing that a single case statement sets up the environment for the shell script to select the correct fields from the sar command for each of the four Unix flavors. If the Unix flavor is not in the list then the user receives an error message before the script exits with a return code of 1 one. Later we will cover the entire shell script. Syntax for vmstat The vmstat command stands for virtual memory statistics. Using the vmstat command we can get a lot of data about the system including memory paging space page faults and CPU statistics. We are concentrating on the CPU statistics in this chapter so let s stay on track. The vmstat commands also allow us to take direct samples over intervals for a specific time period. The vmstat command does not do any averaging for us however we are going to stick with two intervals. The first interval is the average of the system load since the last system reboot like the iostat command. The last line contains the most current sample. Let s look at the output of the vmstat command for each of our Unix flavors AIX .

TỪ KHÓA LIÊN QUAN