Create sensor readings | Computer Science homework help

Create a Sysinfo Protocol client which monitors the system specified. Your program should take a host name and optional port number on the command line. If the port number is not supplied, use 45490. Your client should attempt to connect to the indicated host and port, then monitor its status by printing a message each second. It will continue printing until the status until terminated with control-C. It will need to connect only once, as the protocol allows it to keep the connection open and request status information as many times as needed.

The protocol is a private one, and the only known server implementation presently runs on (If you want to run it on your system, let me know.) Mine client looks a bit like this:

[[email protected]]$ ./statmon
Up 02:40:22.12, 214 procs, 0 users, cpu util 0.025
Up 02:40:23.5, 212 procs, 0 users, cpu util 0.025, 100% idle
Up 02:40:24.89, 214 procs, 0 users, cpu util 0.025, 96.4029% idle
Up 02:40:26.27, 216 procs, 0 users, cpu util 0.025, 95.6522% idle
Up 02:40:27.64, 219 procs, 1 users, cpu util 0.025, 99.2701% idle
Up 02:40:29.03, 217 procs, 1 users, cpu util 0.025, 94.964% idle
Up 02:40:30.41, 217 procs, 1 users, cpu util 0.025, 100% idle
Up 02:40:31.79, 219 procs, 1 users, cpu util 0.025, 97.8261% idle
Up 02:40:33.17, 220 procs, 1 users, cpu util 0.025, 73.913% idle
Up 02:40:34.56, 220 procs, 1 users, cpu util 0.025, 48.2014% idle
Up 02:40:35.94, 220 procs, 1 users, cpu util 0.025, 49.2754% idle
Up 02:40:37.33, 220 procs, 1 users, cpu util 0.025, 50.3597% idle
Up 02:40:38.71, 220 procs, 1 users, cpu util 0.025, 47.1014% idle
Up 02:40:40.08, 220 procs, 1 users, cpu util 0.025, 48.9051% idle
Up 02:40:41.47, 220 procs, 1 users, cpu util 0.025, 48.9209% idle
Up 02:40:42.85, 220 procs, 1 users, cpu util 0.03, 50% idle
Up 02:40:44.24, 218 procs, 1 users, cpu util 0.03, 48.9209% idle
Up 02:40:45.64, 218 procs, 1 users, cpu util 0.03, 49.2857% idle
Up 02:40:47.02, 218 procs, 1 users, cpu util 0.03, 50% idle
Up 02:40:48.41, 220 procs, 1 users, cpu util 0.03, 49.6403% idle
Up 02:40:49.79, 220 procs, 1 users, cpu util 0.03, 47.8261% idle
Up 02:40:51.18, 220 procs, 1 users, cpu util 0.03, 48.9209% idle
Up 02:40:52.56, 220 procs, 1 users, cpu util 0.035, 55.0725% idle
Up 02:40:53.94, 220 procs, 1 users, cpu util 0.035, 100% idle
Up 02:40:55.32, 220 procs, 1 users, cpu util 0.035, 101.449% idle
Up 02:40:56.7, 220 procs, 1 users, cpu util 0.035, 98.5507% idle
Up 02:40:58.08, 220 procs, 1 users, cpu util 0.03, 98.5507% idle
Up 02:40:59.46, 219 procs, 1 users, cpu util 0.03, 95.6522% idle
Up 02:41:00.85, 219 procs, 1 users, cpu util 0.03, 100.719% idle
Up 02:41:02.24, 219 procs, 1 users, cpu util 0.03, 99.2806% idle
Up 02:41:03.62, 219 procs, 1 users, cpu util 0.03, 97.1014% idle
Up 02:41:05.01, 218 procs, 0 users, cpu util 0.03, 93.5252% idle
Up 02:41:06.39, 215 procs, 0 users, cpu util 0.03, 100% idle
Up 02:41:07.77, 213 procs, 0 users, cpu util 0.03, 97.8261% idle
Up 02:41:09.16, 213 procs, 0 users, cpu util 0.03, 100% idle
Up 02:41:10.55, 215 procs, 0 users, cpu util 0.03, 97.1223% idle
Up 02:41:11.93, 215 procs, 0 users, cpu util 0.03, 101.449% idle

Your client should print the following values.

Up Time

This is just the up value fetched from the server, but converted from seconds to some human-readable form in days, hours, minutes and seconds.

Number of Processes

The nproc value returned from the server. It actually includes both processes and threads.

Number of Users

The nuser value provided by the server.

CPU Utilization

This is the qsize divided by the number of CPUs, both values returned from the the sysinfo service.

Idle Percent

This involves a bit of calculation by the client. Each second, you need to fetch the up time and idle time. Take the difference between each new value, and the one from the previous fetch. This will give the change in up time and idle time. The percentage of idle is then just the ratio of these differences (times 100 to make a percentage). Obviously, this ratio is as computed over the previous second. Since your program is taking a new status each second, the up time difference should always be one second, but compute is as described, which will be more precise. Because of the way it is computed, do not print this on the first status report; just the later ones.

Your program should connect to the server, then enter a loop which repeatedly fetches the needed values from the server, then makes a report line. At the bottom of the loop, sleep for one second to create the delay between status lines. On Linux, Unix or Mac, use the Unix sleep call for one second, on Windows, you can use the Win32 Sleep call for 1000 milliseconds. (I believe this also requires #include <windows.h>, but please don’t use other Windows-specific calls.) In either case, the actual delay will be somewhat approximate.

Your client should handle gracefully. A failure to connect to the service should result in a message and program exit. Any failures to fetch needed information, or networking failures during the session, you may handle as you see fit.



Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more