Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment: Operating Systems

Spy

It's nice to be able to track the activities of specific users and/or commands running on your LINUX system. Your assignment is to write a utility program called spy that enables you to do just that.

spy repeatedly scans the system process table, displaying processes that have started or ended since the last scan. The usage of spy is this:
% spy [ list of patterns] [-t secs] [-n count]

Anything enclosed in square brackets is optional. Here's what each field means:

list of patterns:

Is a list of patterns to look out for in the process list, possibly containing regular expressions, described briefly below. If no list is present, spy accepts all processes.

tsecs:

Tells spy how many seconds to wait between each scan of the system process table. The default value is one.

count:

Tells spy how many times the system process table should be scanned before quitting. The default value is five.

During each scan, spy produces an intermediate file containing a list of current processes in the form:

User- id process-id command

which it then compares with the list constructed during the last scan. The differences between the two lists indicate which processes have ended and which have begun since the last scan. This difference is then displayed, in a readable format together with the date and time.

Here's an example of such a process list:

heydari 4286 csh spy lippke smith
heydari 7949 ps -aux

Spy allows you to filter the list for patterns, possibly including regular expressions in the same form as those accepted by the LINIX utility grep.

For example the command:

% spy "^user" vi

would consider all lines in the process list containing vi or beginning with the word user. Similarly, the command:

% spy fox heydari vi -t 10 -n 100

would consider all lines in the process list that contain fox, heydari, or vi. Spy program would iterate 100 times at 10 second intervals.

Error Checking:

Your program should check for simple errors such as missing options (ie. % spy heydari -n, where -n option is used but count is not given). If an error is detected, display an appropriate message and quit. Most utilities present a usage reminder when an ill-formed command line is entered. For example the following error message is appropriate for the following command:

% spy -n

missing count Parameter

Usage: spy [list of patterns] [-t seconds] [-n count]

Sample Output

Here's a sample output from the spy utility, executed from a C shell owned by heydari:

Sat Jan 30 4:15:25 EST 2012
Stared: heydari 26788 csh spy chess fox -t 10
Started: heydari 27258 csh spy
Started: chess 1843 -csh[chess]
Started: fox 24505 -csh[fox]
Started: fox 24713 vi Memo

Sat Jan 30 4:15:35 EST 2012
Ended: fox 24713 vi Memo
Sat Jan 30 4:15:45 EST 2012
Started: fox 87253 lpr
Started: Smith 76532 mail

Sat Jan 30 4:15:55 EST 2012

Sat Jan 30 4:15:65 EST 2012

Note:

It is quite possible that no processes change between scans. In this case, only the time stamp is displayed, please see the last 2 output lines above.

Normally you'd execute spy in the background and redirect its output into a file.

Handling Interrupts:

You will want to create temporary files to hold the process lists between scans. If your shell is interrupted (by a Ctrl-C for example), you don't want these temporary files to be left in your directory, so ensure that interrupts are handled appropriately. You will find the built-in C shell command onintr or trap very useful for this purpose.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92726221

Have any Question?


Related Questions in Computer Engineering

Short answer1 what is the difference between a logic error

Short Answer 1. What is the difference between a logic error and a syntax error? 2. Define and discuss the difference between unary, binary and ternary operators. Give an example of each. 3. When must you use curly brace ...

Suppose kelvin has seven controls listed as the top tier of

Suppose Kelvin has seven controls listed as the top tier of project initiatives. At his next meeting with Charlie, he provides a rank-ordered list of these controls with projected losses over the next 10 years for each i ...

Question suppose that new more powerful arithmetic

Question : Suppose that new, more powerful arithmetic instruction are added to the instruction set. On average, through the use of these more powerful arithmetic instructions, we can reduce the number of arithmetic instr ...

Has a recent drop in airplane passengers resulted in better

Has a recent drop in airplane passengers resulted in better on time performance? Before the recent downturn, one airline bragged that 92% of its flights were on time. A random sample of 165 flights completed this year re ...

Question what are some of the specifics of a dbms that must

Question : What are some of the specifics of a DBMS that must be taken into consideration when building a database design? The response must be typed, single spaced, must be in times new roman font (size 12) and must fol ...

Calculate the energy of one photon of blue light that has a

Calculate the energy of one photon of blue light that has a wavelenght of 425 nm and red light that has a wavelenght of 740 nm. Use E = hv and C = frequency x wavelenght(v). And determine which photon has highest energy.

Describe how to discover cookies on web browsers what is a

Describe how to discover cookies on web browsers. what is a reverse DNS lookup and can it be used when attacking the network.

Determine whether or not the following claim is true for

Determine whether or not the following claim is true for all regular expressions r 1  and r 2 . The symbol ≡ stands for equivalence regular expressions in the sense that both expressions denote the same language. (a) (r ...

Question discuss the advantages and disadvantages of

Question: Discuss the advantages and disadvantages of Incident Response testing. When is each type of testing appropriate? Are there situations that preclude the use of a particular type of testing? Requirement: I recomm ...

Question a description of the tasks and mechanisms that

Question: A description of the tasks and mechanisms that allow you to examine the existing system (a minimum of 3 different tools should be described) A description of conceptual, logical and physical data modeling A des ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As