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 sandbox.mc.edu. (If you want to run it on your system, let me know.) Mine client looks a bit like this:
[[email protected]]$ ./statmon sandbox.mc.edu
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
^C
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.
Submission
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
Custom Writings Help is a Quality-Oriented Company in Online Writing as a result of hiring exceptional professionals to execute clients' tasks.
Essays
At Custom Writings Help,We understand the struggle of research paper writing, and that is why at Custom WritingS Help, we are all out to help you. We pride ourselves on having a team of clinical writers. The stringent and rigorous vetting process ensures that only the 'BEST' Writers are chosen for the job. We have highly qualified Ph.D. and MA writers working with us; we equally offer these experienced writers specific bonuses and incentives to make them deliver highly original, unique, and informative content at reasonably low prices.
Admissions
Thesis Writing Service
Worlwide, Many Masters Students are struggling with Thesis Completion. A thesis is likely to be the longest and most challenging piece of work a student has ever completed. However, unlike essays and other assignments, a student can pick a particular interest topic and work on their initiative. Fortunately, we are there for you. At Custom Writings Help, you are assured of an authentic, imaginative, informative, linguistically great, and advantageous thesis that adheres to all your needs. So, why continue considering different writers when you have discovered the best in the field?
Editing
Custom Papers
Not a single student can avoid writing custom papers. However, a total lack of experience, skills, and time makes it very hard to produce a superb writing piece. Therefore, if you are seeking professional help, turn to us. Our specialized and experienced writers compose a variety of model papers, including custom essays, college term papers, research papers, book reports, MBA essays, executive summaries, dissertations, Ph.D. theses, admission essays, and research proposals for college and university students at any level.
Coursework
Essay Writing
Most of the students disregard the critical principles of essay writing and compose papers below sensible guidelines. Therefore, with Custom Writings Help, one should not worry about his/her essay. Our Writers compose informative and engaging content on all complexities and topics. We write meaningful and smart essays while prioritizing all aspects that bring about a good grade, such as impeccable grammar, proper structure, zero-plagiarism, and conformance to guidelines.
Coursework
Coourse Work Writing
Don't let the seemingly never-ending onslaught of writing assignments get you down. If you are looking where to get course work assistance online, the writers at Custom Writings Help are here to assist you with all of your writing needs. We undertake to unique delivery of papers that meet the professor's requirements. The content is proofread, edited, and checked plagiarism before submission to customers. No matter how big or small your work is, we will deliver on time. Try US Now! !
Coursework
Dissertation Writing Service
High-Quality Dissertation Writing Services are rare. They require Ph.D. academicians – not easily found. However, are an exception. The years, time, and resources we have invested in the dissertation world has given us a competitive advantage over others. Choose to come to Custom Writings Help; You will find perfect Ph.D. consultants who have written hundreds of dissertations theses ready to help you. Let our dissertation-writing services help you craft your dissertation, for you are assured we will give you the results.