Optimizing System by UNIX
The monitor involves several key steps such as reading UNIX command output, data processing, identifying ‘problem’ process, finding user’s email address and sending email notice. Details and tips of each of those steps are discussed.
1. READ FROM COMMAND ‘w’
Several system commands/tools are available for UNIX performance monitoring; this paper uses commands ‘w’ and ‘top’. Processes with a long idling time are screened using the output of the ‘w’ command and processes consuming high system resources will be caught with the ‘top’ command. We start with the output of command ‘w’ since it is easier and output of command ‘top’ will be discussed in the following section. Command ‘w’ with the h option (‘w –h’) presents a list of users and their processes in row and column format. The information provided in the order of columns is user ID, terminal type, login time and idling time, JCPU, PCPU, and process name as the last column. With combination of list input and column input, this output data can be easily handled by ‘filename pipe’. Length of idling time is in cumulative hours; the idling time in number of days, hours, and minutes is calculated.
%*Reading in the output of command ‘w’;
filename wout pipe "w -h";
data woutput(drop=terminal logintm idle jcpu pcpu);
length userid terminal $10 logintm $5 idle $8;
infile wout truncover;
input userid $ terminal $ @23 logintm $5. @30 idle 30-36 jcpu $ 37-44 pcpu $ 45-49 what $140.;
run;
2. READ FROM UNIX COMMAND ‘top’
Command ‘top’ provides a list of the processes using the most CPU, CPU load average and process running time. The information is updated every few seconds. To get a snap shot of such information, one can use the command ‘top –d1’. Unlike the ‘w’ command discussed in the previous section, the ‘top –d1’ command produces an output not completely in row and column format. What is even more complicated is that the output of ‘top –d1’ cannot even be read when reading through ‘filename pipe’ because there are lines with length of over 200 characters. This can be clearly shown if the output is directed to a file and the file is opened with the vi shows that lines 1, 2 and 3 have over 200 characters. These lines cannot be handled by SAS V6.12, since the maximum length of character variable is 200. For SAS Version 8, variable length is not a problem; however the information is still not available when the whole line is read into a single variable since information such as the user ID, process ID and CPU usage are all stacked together. Facing such a challenge, our strategy is to read in the data first, and then break down a single variable to multiple variables to get useful information. By taking a close look, a recurring pattern ‘^[[B’ can be seen. With the help of an editor capable of displaying hexcodes, such as UltraEdit, the ‘^[[B’ has hex code ‘1B5B42’x.
Thus comes the solution, i.e. to use the ‘1B5B42’ as the delimiter to read in the output of command ‘top –d1’. The relevant code is on the next page.
Services: - Optimizing System by UNIX Homework | Optimizing System by UNIX Homework Help | Optimizing System by UNIX Homework Help Services | Live Optimizing System by UNIX Homework Help | Optimizing System by UNIX Homework Tutors | Online Optimizing System by UNIX Homework Help | Optimizing System by UNIX Tutors | Online Optimizing System by UNIX Tutors | Optimizing System by UNIX Homework Services | Optimizing System by UNIX