Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have included what I need to do for part b, and what I have so far. I 2.2 Part B Write a default version

I have included what I need to do for part b, and what I have so far.

Iimage text in transcribedimage text in transcribedimage text in transcribed

2.2 Part B Write a default version of program to report the behavior of the Linux kernel by inspecting kernel state. The program should print the following values to the user screen or console: CPU type and model Kernel version Amount of time since the system was last booted, in thefomdmm:5s (for example, 3 days 13 hours 46 minutes 32 seconds would be formatted as 03:13:46:32) . report date (gettimeofday) and machine hostname 3.2 Using argc and argv If you do Part C or D in addition to Part B, you will need to pass parameters to your program from the shel For example, suppose that your solution program is named observer. To solve Part B, you could call it with observer whereas to solve Part C or D, you could call with observer S If the program is providing information required for Part D, t might be called by $observer -1 10 600 computing information once every 10 seconds until 600 seconds have elapsed. The following code segment is an example for handling the three different ways that observer can be called. A C program may have the header file of the form: int main (int argc, char argv[]) You may omit the two arguments, arge and argv if no parameters are to be passed to the program by the shell. Alternately, they can be initialized so that arge is the number of symbols on the command line and argv is an array of pointers to character strings symbols on the command line. For example, if the observer program is called with no parameters, then arge will be set to 1 and argv[0] will point to the string observer. In the second example, argc will be set to 2, with argvI0] pointing to the string observer and argvl1] pointing to the string-s. The C main program can now reference these arguments as follows #include # i ncl ude #include int main (int argc, char argv) char repTypeName [161 /*Determine report type / reportTypeSTANDARD; 4 strcpy (repTypeName, Standard"); if (argc 1) sscanf (argv [1], "%c%c", &c1, &c2); fprintf (stderr, "usage: observer [-s] l int dur] ") exit (1) if (c2s') reportTypeSHORT strcpy (repTypeName, "Short") if (c2-,1') reportType LONG strcpy (repTypeName, "Long") intervalatoi (argv [2]); durationatoi (argv [3])

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

ISBN: 0805302441, 978-0805302448

More Books

Students also viewed these Databases questions