Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include int main() { time_t current_time = time(NULL); struct tm *local_time = localtime(¤t_time); char time_str[9]; strftime(time_str, 9, %H:%M:%S, local_time); struct sysinfo sys_info; if

image text in transcribed

#include #include #include

int main() { time_t current_time = time(NULL); struct tm *local_time = localtime(¤t_time);

char time_str[9]; strftime(time_str, 9, "%H:%M:%S", local_time);

struct sysinfo sys_info; if (sysinfo(&sys_info) != 0) { fprintf(stderr, "Error: Failed to retrieve system information"); return 1; } double reboot_time_days = sys_info.uptime / 86400.0;

int nprocs_conf = get_nprocs_conf(); int nprocs = get_nprocs();

unsigned long total_memory = sys_info.totalram; total_memory *= sys_info.mem_unit; double total_memory_gb = (double)total_memory / 1073741824;

unsigned long available_memory = sys_info.freeram; available_memory *= sys_info.mem_unit; double available_memory_gb = (double)available_memory / 1073741824;

unsigned long shared_memory = sys_info.sharedram; shared_memory *= sys_info.mem_unit; double shared_memory_mb = (double)shared_memory / 1048576;

unsigned long buffer_memory = sys_info.bufferram; buffer_memory *= sys_info.mem_unit; double buffer_memory_mb = (double)buffer_memory / 1048576;

unsigned long total_swap = sys_info.totalswap; total_swap *= sys_info.mem_unit; double total_swap_mb = (double)total_swap / 1048576;

unsigned long available_swap = sys_info.freeswap; available_swap *= sys_info.mem_unit; double available_swap_mb = (double)available_swap / 1048576;

printf("*** AC0350- Lam Nguyen *** System Info Utility ");

const char *weekdays[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; }

I tried do coding but there were no output at all can someone help me !!!

4. Required System Calls The table below contains the list of system calls you will make as well as related header files that contain the declarations. In addition, there are some notes on how the output needs to be formatted System Information Utility for the utility. For sample data, see the screen captures above. 1. Problem Description Linux systems proliferate, including within our own class. To get a glimpse at the configuration of your Linux installation, you are to write a System Information Utility, called sysutil. The utility will use POSIX system calls to gather and report information on the current time and date, the number of processors and processes and information about memory usage (total memory, available memory, shared memory, etc.) 2. POSIX Documentation The POSIX interface to the OS facilities forms an API: Application Programming Interface. This API is a set of C language functions and variables. On a UNIX system, the functions are mostly system calls which are requests to the OS kernel. To get access to the official POSIX documentation, you will need to register (for free) with the IEEE/Open Group (opengroup.org) and follow the structured information to Library > Standards > UNIX standards > Base Specifications, Issue 7, 2018 Edition. Making systems calls requires knowledge of which functions to call as well as an understanding of the data structures required and returned. The declarations for these calls and structs are found in C header files. For this assignment, I have provided you the names of the calls and the related header files (Section 4, below), but the rest of the research is up to you. 3. Sample Output First, let's look at an example execution of this utility. I have run it on two different Linux installations. 5. Other Requirements/Notes The following list includes other requirements that your program must perform. - The program must print a heading which includes the class name (ACO350) and your name. - The data should be displayed neatly, with the fields lined up as shown in the samples. - The month and day of the week must display as strings, not numbers. - The memory reports should be converted to GB or MB as shown in the table above. Pay attention to the required precision in the numbers. - Turn in your source file: sysutil.c. If you created any other source files, submit them as well. - There is a small starting file in Mod1/sysutil/sysutil.c and a makefile in the same directory

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions