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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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