How many seconds to wait between each scan of the system

Assignment Help Computer Engineering
Reference no: EM131897875

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.

Reference no: EM131897875

Questions Cloud

Determine the rms value of the b-field : The beam is cylindrical with 2.20 mm in radius. Determine the rms value of the B-field?
What is the company new price-to-earnings ratio : LeverCo is financed entirely by equity. The company generates operating profit equal to $80 million. what is the company’s new price-to-earnings ratio?
Discuss how you might use the tools : Within the scope of the lecture, a variety of tools related to research and decision making within an organization are described.
How far away from the earth is the spaceship : The time it takes for sound waves to travel at 328 m/s through the air between the astronauts equals the time it takes for the electromagnetic waves
How many seconds to wait between each scan of the system : Tells spy how many seconds to wait between each scan of the system process table. The default value is one.
Moment of inertia of the turbine engine : A jet turbine engine starts at rest and accelerates to an angular velocity of 1100 rad/s in 38 s. The moment of inertia of the turbine engine is 400kg•m2
How much will you owe in taxes : You are buying a new truck in order to grow your local moving service. How much will you owe in taxes?
Moment of inertia formula : A merry-go-round with a mass of 250kg and a radius of 3 m as a moment of inertia formula of I=m•r2 and is rotating with an angular velocity of 20 rad/s.
Discuss the objectives of a global business environment : Discuss the objectives as they relate to commercial, legal, and cultural aspects of a global business environment. Target Market The target market strategy.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Is statement a above legal or is casting required explain

What is an abstract class and how does it differ from a regular class? Is statement a above legal, or is casting required? Explain

  Define precisely module generic-fifo-queue

Define precisely module GENERIC_FIFO_QUEUE, and instantiate a module that represents the abstract data type queue of integer values.

  What are the two basic forms of compression

What are the two basic forms of compression? Run-length encoding can be used to compress what kind(s) of data?

  What selection criteria would you use

Outline a process for Homestyle to follow in order to decide between the two software options (i.e., HC and CR)? What selection criteria would you use?

  What other solutions might you consider in order to increase

What other solutions might you consider in order to increase throughput and reduce latency? Which solution do you consider to have the better trade-off between performance and complexity?

  Simplex method for the problem to find the optimum solution

Use the simplex method for the problem to find the optimum solution

  Write a function that will scale up just part of the picture

Write a function that will scale up just part of the picture. Try making someone's nose longer. Write a function that will scale down just a part of picture.

  Explain an example of data you had to look

Computer Applications class. Must be 250 words. Explain an example of data you had to look at that would have been easier to understand if a chart had been provided?

  How many bits does the encoded message require

Show the construction process when the method used in the text is used to build the Huffman coding tree. How many bits does the encoded message require?

  Assume you are a wireless network contractor

How would you describe the OSI model to somebody like this potential client who does not have a technical background? Come up with an analogy, that would help clarify your explanation. Note: If you decide to use an analogy it should be original an..

  Calculate and display the miles-per-gallon value

Program that asks the user to enter the number of miles traveled and the number of gallons of gasoline consumed. It should then calculate and display the miles-per-gallon value. Confine your output to 1 decimal place.

  What do you think might happen if situation does not change

What do you think might happen if this situation doesn't change? Is downloading music or videos without paying any different ethically than shoplifting CDs or DVDs from a store? Why or why not?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd