Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

#include #include #include #include int main() { // Current Date time_t current_time = time(NULL); struct tm *local_time = localtime(¤t_time); // Current Time char time_str[9]; strftime(time_str,

image text in transcribed

#include

#include

#include

#include

int main() {

// Current Date

time_t current_time = time(NULL);

struct tm *local_time = localtime(¤t_time);

// Current Time

char time_str[9];

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

// Last reboot

struct sysinfo sys_info;

sysinfo(&sys_info);

double reboot_time_days = sys_info.uptime / 86400.0;

// Number of processors configured and available

int nprocs_conf = get_nprocs_conf();

int nprocs = get_nprocs();

// Memory usage information

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;

// Swap space information

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;

// Print results

printf("*** AC0350- Prof. Eckert *** System Info Utility ");

printf("Current Date: %s, %s %d, %d ",

local_time->tm_wday == 0 ? "Sunday" :

local_time->tm_wday == 1 ? "Monday" :

local_time->tm_wday == 2 ? "Tuesday" :

local_time->tm_wday == 3 ? "Wednesday" :

local_time->tm_wday == 4 ? "Thursday" :

local_time->tm_wday == 5 ? "Friday" : "Saturday",

local_time->tm_mon == 0 ? "January" :

local_time->tm_mon == 1 ? "February" :

local_time->tm_mon == 2 ? "March" :

local_time->tm_mon == 3 ? "April" :

local_time->tm_mon == 4 ? "May" :

local_time->tm_mon == 5 ? "June" :

local_time->tm_mon == 6 ? "July" :

local_time->tm_mon == 7 ? "August" :

local_time->tm_mon == 8 ? "September" :

local_time->tm_mon == 9 ? "October" :

local_time->tm_mon == 10 ? "November" : "December",

local_time->tm_mday, local_time->tm_year + 1900);

printf("Current Time: %s

", time_str);

printf("Last reboot: %.2f seconds (%.2f days)

", sys_info.uptime, reboot_time_days);

printf("Number of processors configured: %d

", nprocs_conf);

printf("Number of processors available: %d

", nprocs);

printf("Number of current processes: %d

", sys_info.procs);

printf("Total usable memory size: %.2f GB

", total_memory_gb);

printf("Available memory size: %.2f GB

", available_memory_gb);

printf("Amount of shared memory: %.2f MB

", shared_memory_mb);

printf("Memory used by buffers: %.2f MB

", buffer_memory_mb);

printf("Total swap space size: %.2f MB

", total_swap_mb);

printf("Swap space available: %.2f MB

", available_swap_mb);

return 0;

}

I THINK SOMETHING WRONG WITH MY CODE. CAN SOMEONE PLEASE TAKE A LOOK AND PERFECT MY CODE PLEASE !!! THANK YOU SO MUCH.

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 Modi/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 with AI-Powered 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

Students also viewed these Databases questions